Schell SortWhile there are several built in alternatives for sorting, this example is the shell sort algorithm for the vArray global variable. The ShellSort procedure needs to know the number of elements in the array to sort, and whether to sort ascending or descending. The Boolean flag is set to True for ascending order, and False for descending order. Fill the vArray elements from index 1 through index Count.
procedure ShellSort(count: integer; b: boolean);
var n: integer;
Notes: You may want to file this example away in your collection of useful routines. Note, the TArray variables have a built in sort method which would be used for TArray variables instead of a routine like today's example.