01How it works
Walk forward; if the current pair is in order, step right; otherwise swap and step left. Unsorted elements are carried back one slot at a time — same effect as insertion sort, but with one index and one loop.
A gnome walks the row, swapping backward until it fits.
Walk forward; if the current pair is in order, step right; otherwise swap and step left. Unsorted elements are carried back one slot at a time — same effect as insertion sort, but with one index and one loop.
Teaching and code-golf — very few lines of logic, no nested loops, trivial to verify by hand. Occasionally appears in size-constrained embedded contexts for the same reason.
Performance matters. Same O(n²) cost as insertion sort with extra pointer bouncing — it's a curiosity more than a tool.