Add functions+tests to Permutation and Sort.