What is the most efficient way to delete a specific object from an array and move it to the beginning?
I have attempted using regular methods such as finding the index, manually splicing, and then moving the object to the top.
farmer: [
{
id:1,
name: "name 1"
},
{
id:2,
name: "name 2"
},
{
id:3,
name: "name 3"
}
]
If I choose the farmer with id: 2, I want to relocate it to the top.