2021-05-07 00:39:20 +02:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 21:56:24 +02:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 21:01:16 +01:00
|
|
|
using System;
|
2018-12-28 00:27:57 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Sorting
|
|
|
|
{
|
|
|
|
public static class SortExtensions
|
|
|
|
{
|
2020-03-02 10:34:34 +01:00
|
|
|
private static readonly AlphanumComparator _comparer = new AlphanumComparator();
|
2020-08-22 21:56:24 +02:00
|
|
|
|
2018-12-28 00:27:57 +01:00
|
|
|
public static IEnumerable<T> OrderByString<T>(this IEnumerable<T> list, Func<T, string> getName)
|
|
|
|
{
|
2020-02-27 12:51:34 +01:00
|
|
|
return list.OrderBy(getName, _comparer);
|
2018-12-28 00:27:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IEnumerable<T> OrderByStringDescending<T>(this IEnumerable<T> list, Func<T, string> getName)
|
|
|
|
{
|
2020-02-27 12:51:34 +01:00
|
|
|
return list.OrderByDescending(getName, _comparer);
|
2018-12-28 00:27:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IOrderedEnumerable<T> ThenByString<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
|
|
|
|
{
|
2020-02-27 12:51:34 +01:00
|
|
|
return list.ThenBy(getName, _comparer);
|
2018-12-28 00:27:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IOrderedEnumerable<T> ThenByStringDescending<T>(this IOrderedEnumerable<T> list, Func<T, string> getName)
|
|
|
|
{
|
2020-02-27 12:51:34 +01:00
|
|
|
return list.ThenByDescending(getName, _comparer);
|
2018-12-28 00:27:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|