'Returns the next permutation in nonlex order [3].
If self is the last permutation in this order it returns None.
Examples
>>> from sympy.combinatorics.permutations import Permutation
>>> Permutation.print_cyclic = False
>>> p = Permutation([2, 0, 3, 1]); p.rank_nonlex()
5
>>> p = p.next_nonlex(); p
Permutation([3, 0, 1, 2])
>>> p.rank_nonlex()
6
See Also
rank_nonlex, unrank_nonlex'

def next_nonlex(self):

    r = self.rank_nonlex()
    if (r == (ifac(self.size) - 1)):
        return None
    return self.unrank_nonlex(self.size, (r + 1))
