I am stuck with an object structure (for now) that I would like to see if I can try to sort. My object looks like this right now -
{
"type1" : {
"position": 3
},
"type2" : {
"position": 1
}
}
And what I am trying to figure out is if there is a way to re order (sort) the object keys/values but that nested position. So the desired outcome would be
{
"type2" : {
"position": 1
},
"type1" : {
"position": 3
}
}
So what would determine the order is that position
value in the object. I am refactoring another project to try an add some sorting to this list. I know it would be much easier if it were a list of objects, but this would require me to change quite a lot of other code so I am trying to find out if I can keep the object structure as is (if possible of course). Thanks for reading!