Open jerrywoo96 opened 8 months ago
Arrays imply a specific ordering, so most use cases would require that arrays do not get sorted as that would change the semantics of the object.
Indeed; I'm not sure why you'd expect it to become sorted.
if the order is not a concern, then sorting it makes it easier to find when looking at a json file? how about adding as an option? like {spaces: 2, sortArray: true}?
If you want it sorted, it should be sorted before trying to stringify it - it doesn't really make sense to me to have a serialization option that fundamentally alters the data.
given:
running
stringify(data, { space: 2 });
does not sort the array. instead, it was unsorted.Result:
Expected: