I got an array that I want to sort depending on a value on my object.
My array looks like this:
[
{
"name": "Ricard Blidstrand",
"number": "5",
"position": "b"
},
{
"name": "Gustaf Thorell",
"number": "12",
"position": "fw"
},
{
"name": "Rasmus Bengtsson",
"number": "13",
"position": "mv"
}
]
I want to order according to the position-key in this order:
mv > b > fw
Do I need to write it like, or am I wrong?
if(a === "b" && b === "b") {
return 0;
} else if (a === "b" && b === "mv") {
return 1;
}