jellyfin-server/MediaBrowser.Controller/Sorting/SortExtensions.cs

34 lines
1.0 KiB
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2018-12-27 23:27:57 +00:00
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Sorting
{
public static class SortExtensions
{
2020-03-02 09:34:34 +00:00
private static readonly AlphanumComparator _comparer = new AlphanumComparator();
2018-12-27 23:27:57 +00:00
public static IEnumerable<T> OrderByString<T>(this IEnumerable<T> list, Func<T, string> getName)
{
return list.OrderBy(getName, _comparer);
2018-12-27 23:27:57 +00:00
}
public static IEnumerable<T> OrderByStringDescending<T>(this IEnumerable<T> list, Func<T, string> getName)
{
return list.OrderByDescending(getName, _comparer);
2018-12-27 23:27:57 +00:00
}
public static IOrderedEnumerable<T> ThenByString<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
{
return list.ThenBy(getName, _comparer);
2018-12-27 23:27:57 +00:00
}
public static IOrderedEnumerable<T> ThenByStringDescending<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
{
return list.ThenByDescending(getName, _comparer);
2018-12-27 23:27:57 +00:00
}
}
}