incoming thread about program synthesis!
specifically, about how feasible it is to start from a fairly intuitive description of a problem (sorting) in natural language and transform that into a mathematical statement, similar to how we do word problems in mathematics or physics
so, one of the classic ways of specifying a sorting algorithm in the functional program synthesis/derivation literature is more or less as follows:
sort xs = head (filter inOrder (permutations xs))