using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace LANCommander.Client.Extensions { internal static class IEnumerableExtensions { static Regex TitleComparisonExpression = new Regex(@"^(?:a|the|an)\s*", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); internal static IOrderedEnumerable OrderByTitle(this IEnumerable items, Func keySelector) { return items.OrderBy(i => { var key = keySelector.Invoke(i); return TitleComparisonExpression.Replace(key, ""); }); } } }