You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Sorting/SortExtensions.cs

35 lines
1.1 KiB

#pragma warning disable CS1591
using System;
6 years ago
using System.Collections.Generic;
using System.Linq;
using Jellyfin.Extensions;
6 years ago
namespace MediaBrowser.Controller.Sorting
{
public static class SortExtensions
{
private static readonly AlphanumericComparator _comparer = new AlphanumericComparator();
6 years ago
public static IEnumerable<T> OrderByString<T>(this IEnumerable<T> list, Func<T, string> getName)
{
return list.OrderBy(getName, _comparer);
6 years ago
}
public static IEnumerable<T> OrderByStringDescending<T>(this IEnumerable<T> list, Func<T, string> getName)
{
return list.OrderByDescending(getName, _comparer);
6 years ago
}
public static IOrderedEnumerable<T> ThenByString<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
{
return list.ThenBy(getName, _comparer);
6 years ago
}
public static IOrderedEnumerable<T> ThenByStringDescending<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
{
return list.ThenByDescending(getName, _comparer);
6 years ago
}
}
}