by Theodis
A library which sorts lists [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Theodis.QuickSort##version=3

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:


Version 3
Date added: May 19 2005
Last updated: Jul 29 2009
6 fans
Sorts a list of items using the quick sort algorithm.

Version 3 - 1/14/2009
Fixed a bug in InsertSort should improve speed slightly as well as
handle sorting subsets properly.

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 2. Plus it looks cleaner.


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.