!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! This is an example of how to use sorting.h, by Fredrik Ramsberg. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Uncomment the following constant definitions in order to make ! the final Zcode file smaller by removing unused routines. ! Constant NOBYTESORT; ! Constant NODIRECTSORT; Include ">sorting.h"; Array arr1 --> 707 91 13 50 23 2 999 34 35 1; Array arr1idx --> 10; ! Must be at least as big as the array being sorted [ lessthan a b; return a < b; ]; [ShowArray arr index from to i; print "Unsorted array: "; for(i=from:i<=to:i++) print arr-->i, " "; print "^^"; print "Sorted array: "; for(i=from:i<=to:i++) print arr-->(index-->i), " "; print "^^"; print "Sorted index: "; for(i=from:i<=to:i++) print index-->i, " "; print "^^^"; ]; ! Main program [main i; ! Sort the array using index-based ShellSort shsort_words_idx( arr1, arr1idx, 0, 9); ShowArray(arr1, arr1idx, 0, 9); print "Random data test:^^"; ! Fill the array with random numbers for(i=0:i<=9:i++) arr1-->i=random(1000); ! Sort the array in descending order using index-based QuickSort qsort_words_idx( arr1, arr1idx, 0, 9, lessthan); ShowArray(arr1, arr1idx, 0, 9); ];