permutation sort algorithm