Add next lexicographical permutation function.