Project Nayuki

Sorting algorithms demo (Java)

Quicksort screenshot
Launcher screenshot

This Java program shows an animation of various sorting algorithms in action, such as bubble sort or quicksort.

The program includes these sorting algorithms: bubble sort, cocktail sort, selection sort, pancake sort, quasi-pancake sort, gnome sort, insertion sort, insertion sort (with binary search), Shell sort, heapsort, quicksort (double-ended), quicksort (sliding), Stooge sort, stupid sort, bozo sort.


Executable JAR file: nayuki-sort-demo.jar

On Windows, simply double click the JAR file to run it. Otherwise, type this on a command line: java -jar nayuki-sort-demo.jar

This contains source code for the application classes but no unit tests.

Source code

Browse the complete source code at GitHub:

Or download a ZIP of all the files:

The code package also includes JUnit test cases for every sorting algorithm to ensure that they are implemented correctly.

The source code is open source under the MIT license.


Note that the videos run at different speeds, so the length of the video is not a reliable indicator of the sorting algorithm’s speed. Check the number of comparisons and swaps to see how much work was actually performed by the algorithm.