Skip to content

Instantly share code, notes, and snippets.

@DanAtkinson
Created May 22, 2012 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanAtkinson/2768287 to your computer and use it in GitHub Desktop.
Save DanAtkinson/2768287 to your computer and use it in GitHub Desktop.
GetTuple extension
//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