On Nov 22, Ben Bush wrote: > I have a list: > [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] > How to remove all the duplicate or same after sorted from the lists? > That is, [1,2] and [2,1] are the same after sorting them. > I want the result to be: > [[1,2],[3,1],[1,4],[3,3]]
You've described the code in words. Next time show the code you tried. Here's one possible solution. First sort each sublist. >>> L1 = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] >>> for i in L1: ... i.sort() ... >>> L1 [[1, 2], [1, 2], [1, 3], [1, 4], [3, 3], [1, 4]] Then add L1's unique items to a new list L2. >>> L2 = [] >>> for i in L1: ... if i not in L2: ... L2.append(i) ... >>> L2 [[1, 2], [1, 3], [1, 4], [3, 3]] This is not identical to your said output, but it sounds like [1,3] == [3,1] for your purposes. -- _ _ ___ |V|icah |- lliott <>< [EMAIL PROTECTED] " " """ -- http://mail.python.org/mailman/listinfo/python-list