JSFiddle - React, Tailwind, and code Playground
JavaScript
function placeZerosAtEnd(arr) {
return arr.sort(compareForSort);
}
function compareForSort(first, second) {
return first == 0 ? 1 : 0;
}
console.log(placeZerosAtEnd([9,0,9,1,0,2,0,1,1,0,3,0,1,9,9,0,0,0,0,0]));