# How to delete duplicate lists of vectors (in any order) from a list of lists?

I have a list of vectors:

v={{{0,0,0},{0,0,1},{1,1,0}},

{{1,0,0},{1,1,1},{0,1,1}},

{{0,0,1},{0,0,0},{1,1,0}}}

Clearly, the first entry and the third entry contain the same vectors. I want to delete one of the duplications but I am not sure how to do this.

I can tell that there is a duplication from

DuplicateFreeQ[v]


which returns True

However, any of the ways that I know how to delete duplicate cases involve having at least 2 different sets. I am not sure how to do this internally?

I tried using DeleteCases and OrderlessPatternSequence but I cannot seem to get it to look through the elements of v and delete duplicate lists that have the same vectors in different orders?

The only thing I can do is

If[MatchQ[Sort[v[[1]]],Sort[v[[3]]],Join[{v[[1]]},{v[[2]]]},v]


Which is pretty useless as I'd have to check through each of the rows manually and Join the non-dduplicate rows manually.

Any hints/tips/suggestions welcome. Thanks!

• DeleteDuplicates[Sort /@ v] Commented Sep 19, 2023 at 16:17

You could just use Union:

Union[Sort /@ v]


You could also use DeleteDuplicatesBy:

DeleteDuplicatesBy[v, Sort]


Another way to do this using GatherByand Union:

GatherBy[Map[Union, v], Union][[All, 1]]

(*{{{0, 0, 0}, {0, 0, 1}, {1, 1, 0}}, {{0, 1, 1}, {1, 0, 0}, {1, 1, 1}}}*)