So, I have an array of objects;
[ { "foo": 2, "bar": "test" }, { "foo": 19, "bar": "value" }, { "foo": 7, "bar": "temp" } ]
I need to move an object with a specific foo value to the beginning of the array. The value is always in the object, but there is no guarantee that the object will be in the array.
So, after running moveToFront(19); For example, I would have the following:
[ { "foo": 19, "bar": "value" }, { "foo": 2, "bar": "test" }, { "foo": 7, "bar": "temp" } ]
How can I do it?
source share