C
C#5mo ago
aria

Multiple arrays. Same objects, different orders. How can I remove the dupes?

hiya! I've an array of arrays, and some may contain the same objects as others. How can i remove the duplicate arrays?
8 Replies
Denis
Denis5mo ago
And result of the operation should be what? Give a couple of example array with duplicates and what you'd expect as a result after removing the duplicates If you want to have a flat array, that contains a list of unique elements from all of your arrays, then that is pretty easy to accomplish with LINQ You'd do a selectMany followed by Distinct Select many will flatten your array of arrays
Angius
Angius5mo ago
Or .DistinctBy() depending on how the equality works between the objects
Denis
Denis5mo ago
thistbh
aria
aria5mo ago
well a smaller array of arrays each one unique in its contents where none of the arrays contain elements from other arrays
Denis
Denis5mo ago
And how would you know where to keep the only occurrence? Given that you have arrays A, B and C And all three arrays have a random set of items And all of these have one item in common - the duplicate Based on which rule you will decide which of the three arrays keeps the item, after the duplicates have been removed? Or none of then keep it and you create a new array? Or let me take a step back and ask this question, how are these arrays created? Can their creation be optimized to prevent duplicates in the first place?
aria
aria5mo ago
nevermind i just did it im so cracked
Denis
Denis5mo ago
Care to share? Otherwise $close
MODiX
MODiX5mo ago
Use the /close command to mark a forum thread as answered