Пример #1
0
 /// <summary>
 /// Sorts the elements in the <see cref="KeyedCollection2{TKey, TItem}"/> by their key value,
 /// using the specified <see cref="IComparer{TKey}"/>.
 /// </summary>
 public void SortByKeys(IComparer<TKey> keyComparer)
 {
     var comparer = new Comparer2<TItem>((x, y) => keyComparer.Compare(GetKeyForItem(x), GetKeyForItem(y)));
     Sort(comparer);
 }
Пример #2
0
 /// <summary>
 /// Sorts the elements in the <see cref="KeyedCollection2{TKey, TItem}"/> by their key value,
 /// using the specified <see cref="Comparison{TKey}"/>.
 /// </summary>
 /// <param name="keyComparison"></param>
 public void SortByKeys(Comparison<TKey> keyComparison)
 {
     var comparer = new Comparer2<TItem>((x, y) => keyComparison(GetKeyForItem(x), GetKeyForItem(y)));
     Sort(comparer);
 }
Пример #3
0
 /// <summary>
 /// Sorts the elements in the <see cref="KeyedCollection2{TKey, TItem}"/> by their values,
 /// using the specified <see cref="Comparison{TItem}"/>.
 /// </summary>
 /// <param name="comparison"></param>
 public void Sort(Comparison<TItem> comparison)
 {
     var newComparer = new Comparer2<TItem>((x, y) => comparison(x, y));
     Sort(newComparer);
 }