I want to sort a list in C#.
Like where structure property AVC goes to true then show them first then AVC goes to false. Are any way to do this in C# LINQ?
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, the simplest way using LINQ would be something like this:
or
I believe that the natural ordering of
boolvalues isfalse < true, but the first form makes it clearer IMO, because everyone knows that0 < 1.Note that this won’t sort the original list itself – it will create a new list, and assign the reference back to the
listvariable. If you want to sort in place, you should use theList<T>.Sortmethod.