C# LINQ Orderby – How does true/false affect orderby?

The OrderBy method will sort items in ascending order by default. Now, given that the numeric representation of a boolean is:

  • false = 0
  • true = 1

false values will naturally come first. If you want to reverse the order just use the descending keyword:

var trueData = (from data in x
               orderby numbersToFilterBy.Contains(data.Id) descending, data.Id
                select data).ToList();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)