From 2e01d82d78c83285c16240b33aa084d1fb950301 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 26 Mar 2018 17:35:56 -0400 Subject: [PATCH] Adding OrderByDescending shim --- .../Extensions/EnumerableExtensions.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs index 59bf4a9..5233bd5 100644 --- a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs +++ b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs @@ -500,7 +500,7 @@ namespace ICD.Common.Utils.Extensions /// /// /// - public static IEnumerable Order(this IEnumerable extends) + public static IOrderedEnumerable Order(this IEnumerable extends) { if (extends == null) throw new ArgumentNullException("extends"); @@ -515,7 +515,7 @@ namespace ICD.Common.Utils.Extensions /// /// /// - public static IEnumerable OrderBy(this IEnumerable extends, IComparer comparer) + public static IOrderedEnumerable OrderBy(this IEnumerable extends, IComparer comparer) { if (extends == null) throw new ArgumentNullException("extends"); @@ -526,6 +526,24 @@ namespace ICD.Common.Utils.Extensions return extends.OrderBy(i => i, comparer); } + /// + /// Shorthand for ordering the given sequence with the given comparer. + /// + /// + /// + /// + /// + public static IOrderedEnumerable OrderByDescending(this IEnumerable extends, IComparer comparer) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (comparer == null) + throw new ArgumentNullException("comparer"); + + return extends.OrderByDescending(i => i, comparer); + } + /// /// Returns every item in the sequence except the given item. ///