Here are some sorting subroutines that implement the quick-sort algorithm. This is an iterative implementation derived from Robert Sedgewick and Jon Bentley 3-way partition quick-sort algorithm.
Implemented in 9.3 Basic.
Usage:
QuickSortFloat(Array To Sort, Starting Index, Ending Index, Descending);
QuickSortInt32(Array To Sort, Starting Index, Ending Index, Descending);
QuickSortInt64(Array To Sort, Starting Index, Ending Index, Descending);
QuickSortString(Array To Sort, Starting Index, Ending Index, Descending);
These subroutines have a substantial performance improvement over the other sorting subroutines I have found for Opto devices. They also sort in situ, so have a minimal memory impact.
Below is the measured sort algorithm performance comparison on an R1.
Last column is running on PAC Sim.
Times are in milliseconds.
Table Length R1 Bubble R1 Insertion R1 Quick Sim i7-4510U Quick
5 3 2 3
10 15 6 7
25 64 32 25 1
50 274 111 64 1
100 1,004 430 142 3
200 4,127 1,778 340 8
400 15,997 6,838 720 18
800 1,550 40
1,600 3,670 73
3,200 7,927 170
6,400 16,946 350
10,000 27,829 567
20,000 1,204
40,000 2,645
80,000 5,547
160,000 11,608
320,000 24,347
640,000 52,337
1,000,000 84,782
Quicksort9.3Basic.zip (11 KB)