def subsets(self, nums):
    """Power set algorithm
    1) set size is n, power set size is 2**n;
    2) loop through power set i:0 -> 2**n-1,
       loop through set j:0 -> n-1
       
    set = [a,b,c] 
    000  []
    001  [a]
    010  [b]
    011  [a,b]
    100  [c] 
    101  [a, c]
    110  [a, b] 
    111  [a, b, c]
    """
    nums = sorted(nums)
    
    n = len(nums) #set size 
    sets = []
    for i in range(1 << n): #1 << n is power set size 
    #retain jth element if match
        sets.append([nums[j] for j in range(n) if (i & (1 << j))]) 
        
    return sets