Suppose I have the following array:
var myArray = ["one", "two", "yay", "something", "something else", "some more"];
If I want to rearrange the array so that the value "yay" is at position 0
var positionOneValue = "yay";
var sortedArray = myArray ...
This is what I tried:
var sorted = myArray.sort((item) => {
if(positionOneValue.match(item))
return item;
return null; // this is probably wrong
})
Can anyone guide me on how to achieve this?