#quicksort is a prime example of an algorithm that is more suited to imperative than functional.
#As it relies on swap in place it can be considered a pathological case for functional programmin
#There are however ways to make it work
#example of some functional approaches to quicksort 
#https://www.youtube.com/watch?v=vzfy4EKwG_Y

set js {

function partition(arr, pivotIndex, low, high) {
    let partitionIndex = low;
    for (let i = low; i< high; i++) {
        if (arr[i] < arr[pivotIndex]) {
            swap(arr, i, partitionIndex);
            partitionIndex++;
        }
    }
    swap(arr, high, partitionIndex);
    return partitionIndex;
}

}