, Javascript. , arround, , , .
:
Javascript sort, . , comparisonFunction, , 2 :
, , :
[5, 2, 4, 1, 3].sort();
[5, 2, 4, 1, 3].sort(function reverse(first, second){
if (first > second) return -1;
if (first == second) return 0;
if (first < second) return 1;
});
[5, 2, 4, 1, 3].sort(function random(first, second){
return Math.floor(Math.random() * 3) - 1;
});
, , , , .