Next permutation
Rearrange an array of numbers into the next permutation in lexicographic order, in place with constant extra memory; if it is the last permutation, wrap around to the smallest.
No answer yet. Write the first one; the best answer gets endorsed.
