JS implementation of quicksort