A logbook for curious waters

Five ways to put things in order

Sorting rearranges items by a chosen value. Here, the goal is ascending numerical order. Switch algorithms to replay the same input; compare sorted, reversed, and repeated values.

Cyan: idle · Pink: inspected · Amber outline: pivot · Green: final position

Labels such as #3 record original input positions. Equal values can have different identities. A highlighted range is currently being processed; a sorted prefix can still move later.

Comparisons
0
Swaps
0
Array writes
0
Recursion depth
0

Current array

IndexValueOriginal position

Sorting pseudocode

Highlighted lines correspond to recorded operations. Counters measure comparisons between item values and writes to the main array; copying the merge buffer is excluded.

Read the executable JavaScript

Explore the lessons

Small input, revealing behavior

Insertion sort can fix a nearly sorted input with very little work. Selection sort scans the remaining items regardless of their order. Merge sort buys predictable performance with temporary storage. Quicksort depends on its pivot and partition rule: this version deliberately uses the last item, making its worst case visible on sorted and all-equal inputs.

Watch equal values’ original-position labels to explore stability. Reset playback returns to the beginning; switching algorithms retains your values. Shuffle changes the input order and assigns fresh identity labels.