QuickSort

A library which sorts lists
Desc:
Sorts a list of items using the quick sort algorithm.

Updates:
Version 2
Tweaked the logic for the cutoff point to check before partitioning rather than after. Might have been the source of bugs with lists smaller than 3. Plus it looks cleaner.


Usage

QuickSort(L[], cmp, start = 1, end = L.len)

L - The list to be sorted
cmp - The comparision function to be used to compare elements in the list
start - The start of the region in the list to be sorted
end - The end of the region in the list to be sorted

The comparision function should take two parameters. The parameters
are the two items being compared. This function should return a negative
number if the first item is less than the second, 0 if the items have
an equal weight for the sorting, and positive if the first item is
larger than the second.

Version 2

  • Date Added: 05/20/05
  • Login to join the waiting list to play live!
  • Open project files

Advertisement