I need to keep the order of my list of objects as it can be changed and reordered anytime in my webapp.
In my model I have a array list of objects example
objectList = [object1, object2, object3, object4]
and I save the order of each object belonging to this instance to a Map example: order
{
"object1":4,
"object2":2,
"object3":1,
"object4":3
}
Therefore i want to sort my array according to its value in the map retrieved by the objects Id as the key:
Expected result:
[object3, object2, object4, object1]
How would I go about doing this?