# Sort 64

Sort 64 is a homebrew demo for the Nintendo 64 by N64 Squid (me) on 03 June 2024. It’s not a game in itself but rather a sorting algorithm visualiser that gives you a few options for sorting lists of integers.

You can find out more about the general sorting algorithm project from this page’s parent page.

You can get the ROM from its download page by using the password `sortitout`

or from the Gitlab releases page.

## Algorithms

Most of the algorithms from the more general Sort project are included, but there are some that were excluded because they were basically just a case of “place elements in a data structure, sort there, and place them back in” so the visualisations wouldn’t be very interesting because everything happens outside of the main array.

- Bubble Sort
- Comb Sort
- Cocktail Sort
- Hanoi Sort
- Proportional Exchange Sort
- Quick Sort
- Slow Sort
- Stooge Sort
- Gnome Sort
- Insertion Sort
- Library Sort
- Shell Sort
- Bingo Sort
- Cycle Sort
- Heap Sort
- Pancake Sort
- Selection Sort
- Smooth Sort
- Weak Heap Sort

- Bogo Sort
- Dumb Bozo Sort
- Smart Bozo Sort
- Brute Force Sort
- Goro Sort
- Poker Sort
- Merge Sort
- In-place Merge Sort
- Quad Sort
- Twin Sort
- American Flag Sort
- Counting Sort
- Flash Sort
- Proxmap Sort
- Batcher’s Odd-Even Sort
- Bitonic Sort
- Odd-Even Sort
- Pairwise Network Sort
- Sample Sort

## Features

The Sort 64 demo has the following features:

- Works on N64 hardware using the Libdragon library
- Uses the core sorting library without affecting its ability to work independently
- Can have the following lists as inputs
- Ascending list
- Descending (reversed) list
- Repeated items
- Random (non-linear) inputs
- Almost-sorted

- Varying array sizes by a factor of 2:
- 256, 128, 64, 32, 16, 8

- Sound with varying frequency based on the index currently being processed:
- No sound
- Sine wave
- Square wave
- Triangle wave
- Sawtooth wave

- Graphical representations:
- None (bar chart)
- Trollface
- 64brew
- Libdragon

- Varying speed:
- One action per frame
- Two actions per frame
- Four actions per frame
- Eight actions per frame
- Sixteen actions per frame
- Thirty-two actions per frame

- Graphical skip at different levels:
- No skip
- Skips the array setup
- Skips data reads
- Skips swaps

- Different resolutions on startup
- High-res 640x480i (Default)
- Low-res 640x240p (Better for CRTs)

## Review and conclusion

I spent about 1 year writing out all the algorithms, then I took a 3 month break learning and writing about Libdragon Trunk, then another 3 months writing the Sort 64 visualiser ROM to make the algorithms work on the N64. Finally I spent another 3 months polishing things up (and procrastinating), and it’s finally here!

A lot of the time spent was doing the write-up and analysis of all the algorithms, you can find that it’s still a work-in-progress here on the website, but I will trickle-down some pages every once in a while to keep this project going.

One of the biggest challenge about this project was the sheer number of algorithms. Every time I wanted to change the way something works (eg adding a description, checking for memory leaks etc), it had to be done on 53 different algorithms just to be sure.

I don’t really like to review my own demos so I’ll really leave it up to you. This is the product of about 18 months of on-and-off work so what initially was meant to be some practice in C programming ended up being this kind of passion project.

I know it doesn’t look like much on the surface since it’s really just a bunch of columns shifting around, but I do find the intricacies of how the algorithm works quite interesting and I hope you do to. I even managed to write a few new ones of my own even if they’re incredibly inefficient.

I do hope you enjoy messing around with the Sort 64 ROM, or you can just watch the video recording of the algorithms that I visualised.