A “sort” that solves disorder by deleting data
Often called Stalin sort, this joke algorithm scans a list from left to right. It keeps the first value, then compares each new value with the last one it kept. If the new value is at least as large, it stays; if it would break the increasing order, it is discarded.
For example, from `3, 1, 2, 4`, the algorithm keeps `3`, rejects `1` and `2`, then keeps `4`. The result, `3, 4`, is ordered—but only because the troublesome entries are gone.
Why it is not a real replacement for sorting
A conventional sorting algorithm rearranges the original values so they appear in order. This one preserves only a subset, so it can lose information and even produce a much shorter list than necessary. In that example, `1, 2, 4` would be a longer increasing subsequence, but the left-to-right rule has already committed to keeping `3`.
The scan itself is simple and takes one pass, making its runtime proportional to the number of items. But speed is not the point: the algorithm’s name and appeal come from its deliberately ruthless tradeoff. It gets an orderly result by treating anything that does not fit the current sequence as expendable—which is precisely why it works as a programming joke, not a dependable way to sort data.






