## On the Subject of Sorting

What is the point of implementing a sorting algorithm if you are going to do it manually anyway?

• The module has a screen and 5 buttons. Refer to the algorithm provided by said screen.

• Positions refer to order from left to right, ignoring vertical offset. For example, 1st position classifies as bottom left.

• It solves when all positions go in ascending value, and strikes if a swap defies the algorithm.
Bubble Sort
Swap them if...
1st position's label is greater than 2nd position's label.
2nd position's label is greater than 3rd position's label.
3rd position's label is greater than 4th position's label.
4th position's label is greater than 5th position's label.
Repeat Bubble Sort.
Slow Sort
Swap them if...
1st position's label is greater than 2nd position's label.
2nd position's label is greater than 3rd position's label.
1st position's label is greater than 2nd position's label.
4th position's label is greater than 5th position's label.
3rd position's label is greater than 5th position's label.
1st position's label is greater than 2nd position's label.
3rd position's label is greater than 4th position's label.
2nd position's label is greater than 4th position's label.
Repeat Slow Sort.
Cycle Sort
If... Then...
1st position isn't smallest? Swap 1st position with the position it will be on assuming it's sorted. Repeat Cycle Sort.
2nd position isn't 2nd smallest? Swap 2nd position with the position it will be on assuming it's sorted. Repeat Cycle Sort.
3rd position isn't 3rd smallest? Swap 3rd position with the position it will be on assuming it's sorted. Repeat Cycle Sort.
Swap 4th position with the position it will be on assuming it's sorted.
Merge Sort
Swap them if...
1st position's label is greater than 2nd position's label.
4th position's label is greater than 5th position's label.
If the first digit in the serial is odd? Otherwise...
Swap 1st position with smallest
label from positions 1-3.
Swap 5th position with greatest
label from positions 3-5.
Swap if 2nd position's label is greater
than 3rd position's label.
Swap if 3rd position's label is greater
than 4th position's label.
Refer to Selection Sort
Insertion Sort
If... Then...
1st position's label is greater than 2nd position's label. Swap them.
2nd position's label is greater than 3rd position's label. Swap them and move up 1 instruction.
3rd position's label is greater than 4th position's label. Swap them and move up 1 instruction.
4th position's label is greater than 5th position's label. Swap them and move up 1 instruction.
Heap Sort
Keep track of the amount of times Heap Sort has been repeated.
If... Then swap them if...
This is the first, or second time doing Heap Sort? 2nd position's label is smaller than 4th position's label.
This is the first time doing Heap Sort? 2nd position's label is smaller than 5th position's label.
This is the first, second, third, or fourth time doing Heap Sort? 1st position's label is smaller than 2nd position's label.
This is the first, second, or third time doing Heap Sort? 1st position's label is smaller than 3rd position's label.
This is the first, or second time doing Heap Sort? 2nd position's label is smaller than 4th position's label.
This is the first time doing Heap Sort? 2nd position's label is smaller than 5th position's label.
Swap 1st position with last unsorted position. Repeat Heap Sort.
If multiple numbers match a rule, positionally leftmost numbers are smaller.
Swap...
The smallest rightmost digit with 1st position.
The 2nd smallest rightmost digit with 2nd position.
The 3rd smallest rightmost digit with 3rd position.
The 4th smallest rightmost digit with 4th position.
The smallest leftmost digit with 1st position.
The 2nd smallest leftmost digit with 2nd position.
The 3rd smallest leftmost digit with 3rd position.
The 4th smallest leftmost digit with 4th position.
If you reach here, sort the remaining labels in any order.
Comb Sort
When starting, distance starts at 3. Skip steps that have 6th/7th/... positions.
Swap them if...
1st position's label is greater than (1st + distance) position's label.
2nd position's label is greater than (2nd + distance) position's label.
3rd position's label is greater than (3rd + distance) position's label.
4th position's label is greater than (4th + distance) position's label.
Decrease distance by 1. Repeat Comb Sort.
Quick Sort
When starting, pivot = 1 and current = 5.
If... Then...
Pivot's and current's positions are not sorted against each other? Swap pivot's and current's position, including their values.
Both are the same value? Otherwise current is 1 closer to pivot. Pivot = earliest unsorted position.
Current = latest unsorted position.
Repeat Quick Sort.
Shell Sort
Swap them if...
1st position's label is greater than 3rd position's label.
2nd position's label is greater than 4th position's label.
3rd position's label is greater than 5th position's label.
1st position's label is greater than 3rd position's label.
Refer to Bubble Sort.
Selection Sort
Swap lowest label and 1st position.
Swap 2nd lowest label and 2nd position.
Swap 3rd lowest label and 3rd position.
Swap 4th and 5th position.
Five Sort
Swap the 3rd largest number with 3rd position.
If... Then...
1st position's label greater
than 3rd largest number?
Swap 1st position with the earliest after
3rd position that is smaller than both.
2nd position's label greater
than 3rd largest number?
Swap 2nd position with the earliest after
3rd position that is smaller than both.
Swap them if...
1st position's label greater than 2nd position.
4th position's label greater than 5th position.
Cocktail Shaker Sort
Swap them if...
Repeat the following instructions in forwards order.
1st position's label is greater than 2nd position's label.
2nd position's label is greater than 3rd position's label.
3rd position's label is greater than 4th position's label.
4th position's label is greater than 5th position's label.
Repeat the previous instructions in backwards order.
Odd-Even Transposition Sort
Swap them if...
1st position's label is greater than 2nd position's label.
3rd position's label is greater than 4th position's label.
2nd position's label is greater than 3rd position's label.
4th position's label is greater than 5th position's label.
Repeat Odd-Even Transposition Sort.
Bogo Sort
You can perform any swap, but with a limit of 250 swaps before automatically striking. The defuser cannot see the labels, but the module is solvable.
You can return to the previous state by pushing any button repeatedly.
Stooge Sort
Second time reached here? N = 2. Otherwise, N = 1.
Refer to Subarray with N.
Refer to Subarray with N + 1.
Refer to Subarray with N.
Repeat Stooge Sort.
Subarray
Swap them if...
Nth position's label is greater than N+1th position's label.
N+1th position's label is greater than N+2th position's label.
Nth position's label is greater than N+1th position's label.
Continue with next entry in Stooge Sort.