<script>
function quickSort(arr) {
var left = [],
right = [];
if (arr.length < 1) {
return arr;
}
var index = Math.floor(arr.length / 2);
var point = arr.splice(index, 1);
for (var i = 0; i < arr.length; i++) {
if (arr[i] < point) {
left.push(arr[i]);
} else {
right.push(arr[i]);
}
}
return quickSort(left).concat(point, quickSort(right));
}
console.log(quickSort([1, 2, 3, 4, 6, 78, 1, 545, 78, 94, 454, 78, 454, 65, 787, 454, 78, 1, 131, 546, 897, 965, 464,
46, 545, 4564, 64, 54, 64, 5548, 78, 9
]))
</script>