```
class Solution {
public:
vector<vector<int>> subsets(vector<int>& nums) {
vector<vector<int>> result;
int n = nums.size();
int N = (1<<n);
int i, j, temp;
result.resize(N, vector<int>(0));
for(i=0; i<N; i++)
{
for(j=0; j<n; j++)
{
temp = (1<<j);
if(i & temp)
result[i].push_back(nums[j]);
}
sort(result[i].begin(), result[i].end());
}
return result;
}
};
```