An program that converts sorting algorithms to MIDI melodies.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A program that converts sorting algorithms to MIDI melodies. Inspired by Sound of Sorting (but is much more musical!).

An array is first filled with 5 octaves of a chosen scale in base C and shuffled. It is then sorted using a chosen sorting algorithm, playing the corresponding note each time an element is moved. The results can be very beautiful or very weird (or both).

If you import the resulting MIDI file into a DAW (Logic Pro in this instance), you can clearly see the patterns created by the sort. It's quite an interesting visualization.

Logic Pro Screenshot

7 sorting algorithms are currently supported:

  1. Bubble Sort
  2. Insertion Sort
  3. Quick Sort
  4. Merge Sort
  5. Heap Sort
  6. Radix Sort (LSD)
  7. Bogo Sort

8 scales are currently supported:

  1. Major
  2. Harmonic Minor
  3. Natural Minor
  4. Melodic Minor
  5. Chromatic
  6. Pentatonic Major
  7. Pentatonic Minor
  8. Blues


Run the program with java -classpath ./bin sorttomidi.SortToMidi and follow the prompts in the console. You can also import this project into Eclipse (File > Open Projects from File System...).