Adding OrderByDescending shim

This commit is contained in:
Chris Cameron
2018-03-26 17:35:56 -04:00
parent 487a2fc006
commit 2e01d82d78

View File

@@ -500,7 +500,7 @@ namespace ICD.Common.Utils.Extensions
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="extends"></param> /// <param name="extends"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> Order<T>(this IEnumerable<T> extends) public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> extends)
{ {
if (extends == null) if (extends == null)
throw new ArgumentNullException("extends"); throw new ArgumentNullException("extends");
@@ -515,7 +515,7 @@ namespace ICD.Common.Utils.Extensions
/// <param name="extends"></param> /// <param name="extends"></param>
/// <param name="comparer"></param> /// <param name="comparer"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> extends, IComparer<T> comparer) public static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> extends, IComparer<T> comparer)
{ {
if (extends == null) if (extends == null)
throw new ArgumentNullException("extends"); throw new ArgumentNullException("extends");
@@ -526,6 +526,24 @@ namespace ICD.Common.Utils.Extensions
return extends.OrderBy(i => i, comparer); return extends.OrderBy(i => i, comparer);
} }
/// <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 IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> extends, IComparer<T> comparer)
{
if (extends == null)
throw new ArgumentNullException("extends");
if (comparer == null)
throw new ArgumentNullException("comparer");
return extends.OrderByDescending(i => i, comparer);
}
/// <summary> /// <summary>
/// Returns every item in the sequence except the given item. /// Returns every item in the sequence except the given item.
/// </summary> /// </summary>