- We look at some item in the array (sometimes the first, some choose the middle). It would be called pivot
- Then you compare for smallers, equals and biggers ones, separating each one in respectives subarrays
- Apply the same procedure on each part (smallers/biggers)
- We continue this until all the numbers are sorted!
QUICKSORT(array):
IF (array.lenght > 1)
choose a pivot
WHILE (there are items left in array):
IF (item < pivot):
put item into smallersarray
ELSE IF (item > piovt):
put item into biggersarray
ELSE
put item into equalsarray
RETURN QUICKSORT(smallersarray) + equalsarray + QUICKSORT(biggersarray)