From c21b8d08da5d00d3210ab7ccb841561ea4e77f42 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 26 Mar 2018 15:39:23 -0400 Subject: [PATCH] Shorthand extension method for ordering a sequence by a comparer --- .../Extensions/EnumerableExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs index 2735f04..59bf4a9 100644 --- a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs +++ b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs @@ -508,6 +508,24 @@ namespace ICD.Common.Utils.Extensions return extends.OrderBy(i => i); } + /// + /// Shorthand for ordering the given sequence with the given comparer. + /// + /// + /// + /// + /// + public static IEnumerable OrderBy(this IEnumerable extends, IComparer comparer) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (comparer == null) + throw new ArgumentNullException("comparer"); + + return extends.OrderBy(i => i, comparer); + } + /// /// Returns every item in the sequence except the given item. ///