Created
May 22, 2012 10:48
-
-
Save DanAtkinson/2768287 to your computer and use it in GitHub Desktop.
GetTuple extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Based on http://stackoverflow.com/a/4785149/31532 | |
public static Tuple<Expression<Func<T, object>>, SortOrder> GetTuple<T>(this IEnumerable<T> source, Expression<Func<T, object>> expression, SortOrder sortOrder) | |
{ | |
return new Tuple<Expression<Func<T, object>>, SortOrder>(expression, sortOrder); | |
} | |
//Usage | |
foreach (var per in people.OrderByMany( | |
people.GetTuple(x => x.Age, SortOrder.Descending), | |
people.GetTuple(x => x.Name, SortOrder.Ascending))) | |
{ | |
Console.WriteLine("{0} Age={1}", per.Name, per.Age); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment