For example, I have a array of objects returned by back-end, with positions as string.
[
{
"color": "red",
"position": "SECOND"
},
{
"color": "blue",
"position": null
},
{
"color": "green",
"position": "FIRST"
},
{
"color": "pink",
"position": "THIRD"
}
]
I need reorganize this array, by key "position", but I need mantein all objects, including nulls in yours original positions (nulls must be after those with position).
[
{
"color": "green",
"position": "FIRST"
},
{
"color": "red",
"position": "SECOND"
},
{
"color": "pink",
"position": "THIRD"
},
{
"color": "blue",
"position": null
},
]
I tryed use a map with possible positions with slice, but my array stays out of order.