```
vector<vector<int> > permute(vector<int> &num)
{
sort(num.begin(), num.end());
vector<vector<int> > rst(1, num);
//get the next array by lexicographical order
while (next_permutation(num.begin(), num.end()))
{
rst.push_back(num);
}
return rst;
}
```