Updated Utilities

This commit is contained in:
Tal Aloni 2016-12-31 13:15:32 +02:00
parent 0ee776be98
commit c73761d36c
6 changed files with 289 additions and 21 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Utilities
{
@ -66,5 +67,35 @@ namespace Utilities
return result;
}
}
new public void Sort()
{
this.Sort(Comparer<TKey>.Default);
}
public void Sort(ListSortDirection sortDirection)
{
Sort(Comparer<TKey>.Default, sortDirection);
}
public void Sort(IComparer<TKey> comparer, ListSortDirection sortDirection)
{
if (sortDirection == ListSortDirection.Ascending)
{
Sort(comparer);
}
else
{
Sort(new ReverseComparer<TKey>(comparer));
}
}
public void Sort(IComparer<TKey> comparer)
{
this.Sort(delegate(KeyValuePair<TKey, TValue> a, KeyValuePair<TKey, TValue> b)
{
return comparer.Compare(a.Key, b.Key);
});
}
}
}