Sort a List of Object in VB.NET

Viewed 144566

I have a list of passengers(object) where it has a differents properties..

passenger.name
passenger.age
passenger.surname

And I want to sort this list by age criterion, how can i do this?

I know in a list of integer/string List.Sort() works, but if is an object list, i dont know if its possible to sort by the value of a object property!

Thanks.

4 Answers

try..

Dim sortedList = From entry In mylist Order By entry.name Ascending Select entry

mylist = sortedList.ToList

Related