Generate all unique permutations of 2d array
Question: I would like to be able to generate all unique permutations of a 2d array in
python.

For example take this 2d array [[1,1],[0,0]] I would like back

    
    
    [[0,0],
    [1,1]]
    
    [[0,1],
    [0,1]]
    
    [[0,1]
    [1,0]]
    
    [[1,0]
    [0,1]]
    
    [[1,0]
    [1,0]]
    
    [[1,1]
    [0,0]]
    


Answer: You can do it like this

    
    
    d = [[1, 1], [0, 0]]
    from itertools import permutations, chain
    from pprint import pprint
    pprint(sorted([i[:2], i[2:]] for i in set(permutations(chain.from_iterable(d)))))
    

**Output**

    
    
    [[[0, 0], [1, 1]],
     [[0, 1], [0, 1]],
     [[0, 1], [1, 0]],
     [[1, 0], [0, 1]],
     [[1, 0], [1, 0]],
     [[1, 1], [0, 0]]]
    

