When I use the orderBy function of Lodash () it returns the array with the correct order, but changes the indexes by simple keys 0,1,2,3... I searched a little bit everywhere, but I couldn't find a solution to keep my keys.
Example :
Data :
var a = {
"65191320": {
"date":"20180220",
"comment":"Hello world"
},
"849165164": {
"date":"20180221",
"comment":"Hello world"
}
}
main.js :
var b = _.orderBy(a, ['date'], ['desc']);
console.log(b);
Output :
{
0: {
"date":"20180221",
"comment":"Hello world"
},
1: {
"date":"20180220",
"comment":"Hello world"
}
}
As you can see, the keys have been changed. Is that common ? How can I keep the keys to the index finger ? Thank you in advance.