JSFiddle - React, Tailwind, and code Playground
by evgkch
JavaScript
function sort(arr, target){
return arr.sort((a, b) => {
if (a == target)
return -1;
else
return 0;
});
}
console.log(
sort([1,2,3,4], 3),
sort([1,2,3,4], 1),
sort([1,2,3,4], 0),
sort([1,2,3,4], 4),
)