Yes, the above is a sorting algorithm. When I arrived at NRL in 1987 I worked on a Cray supercomputer with pipeline parallelization, and it turned out that the compiler couldn't parallelize conditional (if-then) instruction sequences. My ridiculous sorting method proved to be faster than other sorts for small datasets, and could speed up sorting of large datasets when used as the base-case subroutine for quick sort and merge sort, so I published a little paper about it.
Using modular arithmetic it's possible to reduce the above to a single loop so that what it does becomes even more obscure. Fun stuff!