I’ve just been playing around with some numbers and stumbled across this sorting algorithm: Take a set of integers $\{2,2,5,1,1\}$. Count how many numbers you can subtract 1 from (without going negative) - (5)
Same for subtracting 2 - (3)
Same for subtracting 3 - (1)
Same for subtracting 4 - (1)
Finally for subtracting 5 - (1)
This creates a new ordered set $\{5,3,1,1,1\}$ Perform the exact same algorithm with this new set of numbers and it will produce $\{5,2,2,1,1\}$ which is the original set in descending order.
I’m fairly confident the time complexity is $O(n^2)$ (for inputs that are integers smaller than the set size). I can draw a diagram confirming that it works too. Just wondering if it already has a name? Thanks in advance
This algorithm is essentially counting sort
https://en.m.wikipedia.org/wiki/Counting_sort?fbclid=IwAR1XKmg3EuxUBqJOfTm4HTo8YuOXgP_ZDHy6qIBDR_4cTUqr70DTeT9wiRw
This algorithm can be computed in a single step when there is a diagonal symmetry in the Ferrer diagram
E.g permutations of 5,3,2,1,1
Or permutations of 4,3,2,1