OrderBy Observable集合的降序 - UWP

时间:2018-02-23 04:03:04

标签: c# sorting uwp observablecollection

我可以使用下面的代码通过我的可观察集合进行排序。我如何按降序排序?

  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

1 个答案:

答案 0 :(得分:1)

使用Linq OrderByDescending 代替OrderBy:

_mainItems.SubItemsList.OrderByDescending(i => i.num).ToList();