Shorthand extension method for ordering a sequence by a comparer

This commit is contained in:
Chris Cameron
2018-03-26 15:39:23 -04:00
parent 60137254da
commit c21b8d08da

View File

@@ -508,6 +508,24 @@ namespace ICD.Common.Utils.Extensions
return extends.OrderBy(i => i);
}
/// <summary>
/// Shorthand for ordering the given sequence with the given comparer.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="comparer"></param>
/// <returns></returns>
public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> extends, IComparer<T> comparer)
{
if (extends == null)
throw new ArgumentNullException("extends");
if (comparer == null)
throw new ArgumentNullException("comparer");
return extends.OrderBy(i => i, comparer);
}
/// <summary>
/// Returns every item in the sequence except the given item.
/// </summary>