This problem was first proposed by E.W Dijkstra in 1976 (in the chapter 14 of his book "A Discipline of Programming"). It is a very classical variation of the sorting algorithms since then. It is sometimes useful in real life, but it became famous for its pedagogical properties: its complexity is not trivial, but not complex either. It can easily be formally proven, but it's not absolutely trivial either.
As usual, there are several things that could be done in the code of this universe to improve it: