I have a MyObject class that contains a CreationDate As Date Property.
What is the best way to obtain a sorted by CreationDate List(Of MyObject)?
The quicker way and the most performant one.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well with LINQ you could use:
EDIT: If you’ve already got a
List(Of T)you could use the in-placeSortmethod with a custom comparer. That may be faster. It may not. I suspect it’s unlikely to be a significant difference in performance, which is what you should be concerned about.As a rule of thumb, I’d suggest: