I need some help to shift the position index in the array of objects. I am having a bunch of arrays of objects which need to be shifted at index 0 or 1 based on value key.
const arrayObj1 = [
{
id: 234,
value: "FGH"
},
{
id: 454,
value: "XYZ"
},
{
id: 654,
value: "ABC"
},
{
id: 543,
value: "ABC"
},
]
Let say I have above array of objects, and I want to shift position to index 0, 1 if the value is "ABC". As of now they are positioning at index 2 and 3. So the array of object will be looks like below after shifting their position.
expectedArrayofObj = [
{
id: 654,
value: "ABC"
},
{
id: 543,
value: "ABC"
},
{
id: 234,
value: "FGH"
},
{
id: 454,
value: "XYZ"
},
]