I'll show you next_permutation(v.begin(), v.end()) to generate the next lexicographical arrangement. It returns false when you reach the last permutation. You'll typically use this in a loop: while (next_permutation(v.begin(), v.end())) to try all arrangements.
Start with a sorted vector. For elements, there are permutations. This gets slow quickly: 10 elements means 3.6 million permutations.