Neat JS sort function
Array.prototype.nSort = nSort;
// [].prototype.nSort works too
function nSort(){
return this.sort(
function numSort(n1, n2){
if (n1 < n2) return -1;
if (n1 > n2) return 1;
return 0;
}
);
}
var numbers = [];
numbers[0] = 20;
numbers[1] = 22;
numbers[2] = 21;
numbers[3] = 19;
console.log(numbers.nSort())