The sort maintains a sorted (left) and unsorted (right) sections. As each value is checked, if it's greater than the previous value it gets swapped to the left until it is no longer greater.
array(Array): the input array[comparator](Function): a function to compare2values *(defaults asc->desc)*[step](Function): an optional function that gets applied at each step
(Array): the sorted array