Please enable JavaScript to view this site.

KOL/MCK - User Guide

Data sorting: quicksort implementation

 

This part contains implementation of 'quick sort' algorithm, based on following code:

 

TQSort by Mike Junkin 10/19/95.

DoQSort routine adapted from Peter Szymiczek's QSort procedure which was presented in issue#8 of The Unofficial Delphi Newsletter.

TQSort changed by Vladimir Kladov (Mr.Bonanzas) to allow 32-bit sorting (of big arrays with more than 64K elements).

Finally, this sort procedure is adapted to XCL (and then to KOL) requirements (no references to SysUtils, Classes etc. TQSort object is transferred to a single procedure call and DoQSort method is renamed to SortData - which is a regular procedure now).

 

 

The most efficient method for performing sorting is the so-called Quick Sort algorithm. The KOL library has an optimized (and assembled) version of this function called SortData. (And with version 3.00, the SortArray function was added, which provides slightly better performance for arrays and lists of 4-byte values, such as Integer numbers or in-memory string pointers.)

 

To use the SortData function, you need to set 4 parameters: an object for sorting (usually, it is some kind of list or array), the number of elements in the list, as well as a function for comparing two elements and a procedure for exchanging two elements of the array being sorted.

 

As an example of using the SortData and SortArray functions, it is recommended to study the implementation of the SortIntegerArray and SortDwordArray functions, which are also included in the library.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC