Fix folly json to only sort properties of objects based on their key not value.
authorMichael O'Farrell <michaelofarrell@fb.com>
Mon, 9 Jan 2017 15:22:20 +0000 (07:22 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 9 Jan 2017 15:33:02 +0000 (07:33 -0800)
Reviewed By: yfeldblum

Differential Revision: D4386258

fbshipit-source-id: 23499267eb4390f0f40b3643760514cae1ca7838

folly/json.cpp

index 5adf787d2186a0538b9b08240003396d22c9a140..6f8ecdbc4d443292abfd49ff1cabaef4c284e814 100644 (file)
@@ -113,7 +113,10 @@ private:
     if (opts_.sort_keys) {
       std::vector<std::pair<dynamic, dynamic>> 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());