Quicksort implementation in JavaScript