I have an extension class that is converting an Observable collection to list and performing an order by. This logic is working but I need it to sort Alpha-numeric as well. E.g.
In lieu of A1 A10 A2 A3 should be A1 A2 A3 A10.
What is the best way to go about this?
<pre>
public static void Sort<T>(this ObservableCollection<T> collection, Comparison<T> comparison)
{
var comparer = new Comparer<T>(comparison);
List<T> sorted = collection.OrderBy(x => x, comparer).ToList();
for (int i = 0; i < sorted.Count(); i++)
collection.Move(collection.IndexOf(sorted[i]), i);
}
internal class Comparer<T> : IComparer<T>
{
private readonly Comparison<T> comparison;
public Comparer(Comparison<T> comparison)
{
this.comparison = comparison;
}
#region IComparer<T> Members
public int Compare(T x, T y)
{
return comparison.Invoke(x, y);
}
}
</pre>