Fix folly json to only sort properties of objects based on their key not value.
[folly.git] / 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());