binary sorting method of arrays:
function quickSort (arr) {
if (!Array.isArray(arr) || arr.length == 0) {
return [];
};
var cIndex = Math.floor(arr.length / 2),
c = arr.splice(cIndex,1),
l = [],
r = [];
for (var i = 0; i < arr.length; iPP) {
if (arr[i] < c) {
l.push(arr[i]);
} else{
r.push(arr[i]);
};
};
return quickSort(l).concat(c,quickSort(r));
};
The comparison of arr [I] < c in is actually similar to the question I asked. How does a number compare with an array?