|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace CustomSorter
{
public static class ListExtension
{
public static void Sort<T, TResult>(this IList<T> source, Expression<Func<T, TResult>> property, string order) where T : class
{
Sort(source, property, order, StringComparison.CurrentCulture);
}
public static void Sort<T, TResult>(this IList<T> source, Expression<Func<T, TResult>> property, string order, StringComparison comparison) where T : class
{
var propertyList = new List<Expression<Func<T, TResult>>>();
propertyList.Add(property);
var orderList = new List<string>();
orderList.Add(order);
var sorter = new Sorter<T, TResult>();
sorter.Add(property, order, comparison);
sorter.Sort(source);
}
public static void Sort<T, TResult>(this IList<T> source, Sorter<T, TResult> sorter) where T : class
{
sorter.Sort(source);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am an independent IT contractor who is passionate about life and Microsoft technology stack. I have been programming since 2001. Besides coding, I also enjoy diving, swimming, rock climbing and travelling. I swim 2 miles a day to keep my morale and energy level consistently high.