sort order of arrays #4327
Unanswered
stephanecharette
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I can confirm it should work, but since you found a way where it does not, I would be happy to see a concrete example so I could debug into it. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I understand from issues such as #727 that key-value pairs are sorted alphabetically since a std::map is used.
But what about arrays? Are they stored in a std::vector which may be easily sorted? I attempted to std::sort an array, and while this initially seemed to work, with some JSONs we're seeing asserts and C++ exceptions from deep within the nlohmann library. This makes me think we should not be messing with the internals.
The code we had attempted to use was something like this:
Most of the time this appeared to work. But every once in a while this would do stuff like rhs would be null, we'd get an assert, or a C++ exception would be thrown.
Some of the asserts I saw earlier today which I still have on my screen:
Can someone confirm or deny that we can/cannot std::sort json arrays?
Beta Was this translation helpful? Give feedback.
All reactions