function quicksort(items, low=0, high=None):

   if high is None: high = length(items) - 1
   if low < high:
      pivot_index = partition(items, low, high)
      quicksort(items, low, pivot_index - 1)
      quicksort(items, pivot_index + 1, high)


 function partition(items, low, high):
   pivot = items[high]
   i = low - 1
   for j from low to high - 1:
      if items[j] <= pivot:

        i += 1
        swap(items, i, j)
   swap(items, i + 1, high)
   return i + 1
