I have an array of Objects and I want to sort it customarily.
var array = [
{
"1":1223,
"3":1224,
"2":1225,
"some_field":"Name1",
"row":1,
"col":1
},
{
"3":10,
"2":11,
"1":12,
"some_field":"Name2",
"row":2,
"col":1
}
]
I need output like this
[
{
"some_field":"Name1",
"row":1,
"col":1,
"1":1223,
"2":1224,
"3":1225
},
{
"some_field":"Name2",
"row":2,
"col":1,
"1":10,
"2":11,
"3":12
}
]
How can I sort them like this? Do I need to use the length of each index and sort in descending order?