The SORT class 

The sort class has code for six sorting algorithms and has the following methods,

 Method   Operation 
transfer Transfer data from the main program to the sort object
retirn Return data from the sort object to the main program
bubble_srt Sort the data using a bubble sort
exchange_srt Sort the data using an exchange sort
insertion_srt Sort the data using an insertion sort
quick_srt Sort the data using a quick sort
shell_srt Sort the data using a Shell-Mietzner sort
tree_srt Sort the data using a tree sort
MF_srt a multi-field, indexed Shell sort

The main demonstrations allow the production of either a set of integer data or string data which can be sorted and timed by each of the methods.

The multi-field, Shell sort could be adapted for any of the other algorithms.

The multi-field demonstration generates an integer or string data set with up to ten fields which can be sorted on any selection of these ten, taken in any order by the MF_srt method.

There is also an option to sort names according to the UK English conventions and a data file, name.dta, to demonstrate this.

To allow for different types of data, the code is written using variant variables but could be re-dimensioned to fit specific data types so as to reduce memory usage and speed up the sorts.