# DeleteDuplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me.

The Math Problem:

list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}};


as you know that list is a List,

and the first three elements of the list is list[[1]]、list[[2]]、list[[3]].

but the three elements of list[[1]]、list[[2]]、list[[3]] are all the same, that is 1,0,0.

the only difference is their order.

So I need a function to deal with the List:

The Results must been p={{0,0,1} ,{1,2,3}} (also can been p={{1,0,0} ,{1,2,3}},etc).

I know two functions can do that:

(1)

p = DeleteDuplicates [ list, Sort[#1] == Sort[#2] & ];


(2)

p = Union[list,  SameTest -> (SameQ[Sort[#1], Sort[#2]] &) ]


when List has 100,000 elements (Length[list]=100,000) , the speeds of these two functions

eg

list={};
For[i=1,i<=100000,i++,
list=Append[list,{0,0,Random[Integer,{1,5}]}]
];
p = DeleteDuplicates [ list, Sort[#1] == Sort[#2] & ];


Could you help me or give some suggestions ?

## marked as duplicate by Mr.Wizard♦Jul 18 '14 at 12:47

• Can you not simply sort the subsets?: DeleteDuplicates[Sort /@ set] – Mr.Wizard Jul 18 '14 at 12:39
• I have marked this question as a duplicate of one that I believe is equivalent. Please take a look at it. (The link is now at the top of your question.) The solution is to use GatherBy rather than DeleteDuplicates with a custom comparator, so you want: First /@ GatherBy[set, Sort]. The reason why is explained in my answer there. – Mr.Wizard Jul 18 '14 at 12:49