removed unnecessary permutation reset for sorting
permutation stuff (nice algorithm to in-place apply permutations via swap operations)