Below is the structure of my JSON data :
Root
|- cells []
|-Individual cells with the following
|- Facts (Object)
|- Measures (Object)
|- Key value pairs
|- other values
My goal is to sort the values in the measures object in-place. Is this possible? If not, what would be the most efficient approach? One option could be to extract the values into a temporary array, sort them, and then rearrange the keys in the JSON structure. However, this doesn't seem like an optimized solution.
I am attempting to achieve sorting in the jsHypercube library : https://github.com/thesmart/js-hypercube . I have searched the library but couldn't find a built-in sort method.
Here is a sample JSON snapshot :
The desired output is a sorted array of _cells
based on any key in the measures
object, such as Cost, Profit, or Revenue.
Based on the feedback from @FelixKling, I believe the data should be sorted prior to serialization into a JavaScript Object. The initial data before serialization :