```
vector<vector<int>> subsets(vector<int>& nums) {
sort(nums.begin(),nums.end());
vector<int> s;
vector<vector<int>> result(1,s);
int n = nums.size(),j;
for(int i = 0 ; i+1<1<<n;i++)
{
for(j = 0; (i>>j)&1;j++) s.pop_back();
s.push_back(nums[n - j - 1]);
result.push_back(s);
}
return result;
}
```