```
vector<vector<int>> permute( vector<int> &nums ) {
std::sort( nums.begin(), nums.end() );
vector<vector<int>> result{ nums };
while( std::next_permutation( nums.begin(), nums.end() ) )
result.push_back( nums );
return result;
}
```