Range based lexicographic permutation.