我可以使用下面的代码通过我的可观察集合进行排序。我如何按降序排序?
RollNoArray _mainItems = new RollNoArray();
_mainItems.SubItemsList = new ObservableCollection<SubItems>();
//..adding data to _mainItems.SubItemsList here
_mainItems.SubItemsList = new ObservableCollection<SubItems>
(from i in _mainItems.SubItemsList orderby i.num select i);// order by num
答案 0 :(得分:1)
使用Linq OrderByDescending 代替OrderBy:
_mainItems.SubItemsList.OrderByDescending(i => i.num).ToList();