Try to think about how you generate all the permutations on a piece of paper.
You start from the rightmost number and move one position to the left until you see a number smaller than its neighbor. Then you put the number next in value there and order all the remaining numbers in ascending order after it. Do this while you have nothing more to do. Think about it, and you can order numbers in linear time relative to their number.
This is actually a typical algorithm used for the next permutation, as far as I know. I see no reason why this would be faster in the array than in the list.
source share