Added lexicographic order for permutations.