Generates permutations with lexicographic order or by minimum change