Search results

Uparrow
0
Downarrow
Daniel Ge

function chSort(list) {
var max = list[0],
min = list[0],
asc = !0;
for (i in list) list[i] > max ? max = list[i] : list[i] < min && (min = list[i]), list[i - 1] > list[i] && (asc = !1);
if (asc) return list;
var minList = [],
maxList = [],
pivot = min + (max - min) / 2;
for (i in list) (list[i] > pivot ? maxList : minList).push(list[i]);
return [].concat(chSort(minList), chSort(maxList));
};

A tiny implementation of quick sort in JS (http://www.reddit.com/r/tinycode/c...
created about 6 years ago

Tags: javascript quick-sort