def qsort(lst):
 if (len(lst) <= 1):
  return lst
 (pivot, rest) = (lst[0], lst[1:])
 less_than = []
 for lt in rest:
  if (lt < pivot):
   less_than.append(lt)
 greater_equal = []
 for ge in rest:
  if (ge >= pivot):
   greater_equal.append(ge)
 return ((qsort(less_than) + [pivot]) + qsort(greater_equal))

def qsort ( lst ) : if ( len ( lst ) <= 1 ) : return lst ( pivot , rest ) = ( lst [ 0 ] , lst [ 1 : ] ) less_than = [ ] for lt in rest : if ( lt < pivot ) : less_than . append ( lt ) greater_equal = [ ] for ge in rest : if ( ge >= pivot ) : greater_equal . append ( ge ) return ( ( qsort ( less_than ) + [ pivot ] ) + qsort ( greater_equal ) )
quicksort in o and no extra memory .