Linq orderyby boolean
Use the order by descending
option and it will reverse the list. See MSDN Soring Data for more examples on sorting.
return from workers in db.Workers
orderby workers.active descending, workers.naam
select workers;
The OrderBy method will sort items in ascending order by default. Now, given that the numeric representation of a boolean is:
false
= 0true
= 1
false
values will naturally come first. If you want to reverse the order just use the descending
keyword:
return from workers in db.Workers
orderby workers.active descending, workers.naam
select workers;