Stalin Sort
Elements that are out of order are simply eliminated. The survivors are sorted. O(n) time, comrade.
0 elements
>Ready — Stalin Sort
Code
1
2
3
4
5
6
7
8
Analysis
BEST O(n)
AVG O(n)
WORST O(n)
SPACE O(1)
Stalin Sort iterates through the array once. Any element smaller than the previous one is “purged.” The remaining elements are, by definition, in sorted order. It’s O(n) and technically correct — the best kind of correct. The downside is your array gets shorter. A lot shorter. But the survivors are very well organized.