- Home /
Question by
User Banned · Jun 15, 2013 at 07:24 PM ·
listsortlinq
LINQ to OrderBy, Distinct and RemoveAll List of GameObjects
LINQ newb here, I was wondering if somebody could give me some pointers, because i have no idea what is going on.
I have a List of GameObjects and wish to sort it and remove dupes and entries which no longer exist. I can do the first two with separate LINQ statements but cannot string them for the life of me.
//--Works
myList = myList.Distinct ().ToList ();
myList = myList.OrderBy (x => x.name).ToList ();
//--Doesnt Work
myList = myList.Distinct ().OrderBy (x => x.name).ToList ();
Now i understand that Distinct() and OrderBy() have problems with each other but apparently they should work in that order, yet they dont. Further to that i cant get RemoveAll to work whatsoever.
Anybody care to have a stab?
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Sort List by string field 1 Answer
What is the quickest way of getting the most common item in a list or array? 1 Answer
sort List alphabetically 2 Answers