I have this associative array :
Arr = {
"ID1":{"Attr1":"b","Attr2":"5"},
"ID2":{"Attr1":"d","Attr2":"2"},
"ID3":{"Attr1":"h","Attr2":"8"}
}
and I want to sort it with the attribute 2 by numbers and not the ID in descending Order to obtain this result :
Arr = {
"ID3":{"Attr1":"h","Attr2":"8"}
"ID1":{"Attr1":"b","Attr2":"5"},
"ID2":{"Attr1":"d","Attr2":"2"},
}
If this possible ?
By invoking
Object.keysandArray.prototype.sort, you can at least sort the keys of any object. With that, you can access those key / value pairs in order.The output of the above snippet is