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
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
Or
.DistinctBy()
depending on how the equality works between the objectswell
a smaller array of arrays
each one unique in its contents
where none of the arrays contain elements from other arrays
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?
nevermind i just did it
im so cracked
Care to share?
Otherwise $close
Use the /close command to mark a forum thread as answered