QuickSort implementation in JavaScript