Slap sort is such a sorting strategy:
- Repeatedly move to end the first element which is larger than the following element, until sorted(aka. no such element exist).
This is easily coded when elements are stored in a gravity stack, e.g. in game EXAPUNKS.
Now, given some values, count how many operations done during this sorting process.
I decide that input is a permutation of {1,2,3,...,n} since that shouldn't help a pure simulation but may help formula-based solution(if it exists) which I encourage.
Example
Given array [3,2,1], it goes like following:
[3]2 1
[2]1 3
1[3]2
1 2 3
which takes 3 steps.
Test cases
3,2,1 => 3
1,3,5,2,4 => 5
1,2,5,3,4 => 1
3,6,5,4,1,2 => 10
2,5,1,3,4 => 8
Shortest code in each language wins.

a>sorted(a)anda!=sorted(a)should work same \$\endgroup\$Retry:while(p[0]/*require use of register*/<=p[1])++p;reg=*p;erase(*p);p=end();put(p,reg);p=begin();goto Retry;Also I'm recently on Manufactoria where data is stored in a queue and slap sort on binary array take O(n) steps or say O(n^2) queue operations. \$\endgroup\$