This might help this do without affecting order of category item
var WithoutNull =
(from item in Items
where !string.IsNullOrEmpty(item.Category)
select item.Category).ToList();
var WtihNull=
from item in db.SomeTable
where string.IsNullOrEmpty(item.Category)
select item.Category).ToList();
var allvalues= WithoutNull.Concat(WtihNull)
.ToList();
I think orderby
or OrderByDescending
clause will do the work for you easily...apply as per your need
var groups = Items.Select(g => g.Category).Distinct().OrderBy(g => g.Key);
or
var groups = Items.OrderBy(g => g.Category).Select(g => g.Category).Distinct();