function quicksort(items) { if(count(items) <= 1) { return a } middle_idx = count(items)/2; pivot = []; pivot[] = items[middle_idx]; before_list = after_list = []; for(i in items) { if(items[i] < pivot) { before_list[] = items[i]; } else if(items[i] > pivot) { after_list[] = items[i]; } else { pivot[] = items[i]; } } return concatenate(quicksort(before_list), pivot, quicksort(after_list)); }
Wikipedia Article [http://en.wikipedia.org/wiki/Quicksort]