There is such an object:
data['params']['last_name']['property_xxc'] = 'abcd'; data['params']['last_name']['sort_index'] = 2; data['params']['name']['property_erw'] = 'abcd'; data['params']['name']['sort_index'] = 5; data['params']['date']['property_xxc'] = 'abcd'; data['params']['date']['sort_index'] = 3; This object with such a deep nesting, you need to sort by the floor sort_index , in the end you need to get such an object:
data['params']['name']['property_erw'] = 'abcd'; data['params']['name']['sort_index'] = 5; data['params']['date']['property_xxc'] = 'abcd'; data['params']['date']['sort_index'] = 3; data['params']['last_name']['property_xxc'] = 'abcd'; data['params']['last_name']['sort_index'] = 2; I tried to sort using sort() like this:
var compareData = (a, b) =>{ return a.sort_index - b.sort_index; }; But nothing happened. Tell me how to do this sorting?
sortmethod? - Dmitriy SimushevJSON.stringifynot guaranteed. If you need guaranteed sorting, why not change the data format to sortable? - Nick Volynkin ♦