```
vector<vector<int> > permute(vector<int> &num) {
vector<vector<int> > p;
if(num.size() == 0) return p;
sort(num.begin(), num.end());
do{
p.push_back(num);
}while(next_permutation(num.begin(), num.end()));
return p;
}
```