The SortDetective program is written in Java using JavaPowerTools (JPT) classes from Northeastern University. The two main classes are SortDetective and SortingExperiment. SortDetective creates the user interface using JPT; it is here that the number of buttons is set, the labels chosen, and the mapping of buttons to algorithms is completed. SortingExperiment contains the actual sorting algorithms. To create an application, compile these two classes together with the JPT archive file; the main class is SortDetective.
Changing the Button Mappings
It is likely that over time, you will wish to change either the number of sorts, the button names, or (most likely), the mapping between buttons and algorithms. The code that handles this is in lines 178-203 of the file SortDetective.java. The button labels are stored in the array of Strings named buttonNames. The actual mapping of algorithms is handled during the initialization of the array of Actions named sorts. Making the obvious changes there will have the obvious results.
Adding a New Sorting Algorithm/Modifying an Existing Algorithm
The algorithms themselves are found in the file SortingExperiment.java. Each algorithm is represented by a static object. New algorithms should be added by mimickry. Each algorithm may assume that the counters movements and comparisons start at zero; it should update them accordingly. It needn't worry about the timing.