From: Michael O'Farrell Date: Mon, 9 Jan 2017 15:22:20 +0000 (-0800) Subject: Fix folly json to only sort properties of objects based on their key not value. X-Git-Tag: v2017.03.06.00~117 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05d3945f70faeed41a24a801c9703ad8397fc0cb;p=folly.git Fix folly json to only sort properties of objects based on their key not value. Reviewed By: yfeldblum Differential Revision: D4386258 fbshipit-source-id: 23499267eb4390f0f40b3643760514cae1ca7838 --- diff --git a/folly/json.cpp b/folly/json.cpp index 5adf787d..6f8ecdbc 100644 --- a/folly/json.cpp +++ b/folly/json.cpp @@ -113,7 +113,10 @@ private: if (opts_.sort_keys) { std::vector> items( o.items().begin(), o.items().end()); - std::sort(items.begin(), items.end()); + std::sort(items.begin(), items.end(), [](auto const& a, auto const& b) { + // Only compare keys. No ordering among identical keys. + return a.first < b.first; + }); printKVPairs(items.begin(), items.end()); } else { printKVPairs(o.items().begin(), o.items().end());