Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 848 Bytes

File metadata and controls

31 lines (19 loc) · 848 Bytes

Sort.QuickSort

export function QuickSort *(array(array, [comparator], [step])*

Quicksort chooses an element of the array to serve as the pivot element and then moves two pointers in from the ends of the array until values are found that should be swapped to have a more sorted array this is then done recursively the subarray contained on each side of the pivot until fully sorted.

Arguments

  1. array (Array): the input array
  2. [comparator] (Function): a function to compare 2 values *(defaults asc->desc)*
  3. [step] (Function): an optional function that gets applied at each step

Returns

(Array): the sorted array