| | 1 | | using System; |
| | 2 | | using Jellyfin.Data.Enums; |
| | 3 | | using MediaBrowser.Controller.Entities; |
| | 4 | | using MediaBrowser.Controller.Entities.Audio; |
| | 5 | | using MediaBrowser.Controller.Sorting; |
| | 6 | | using MediaBrowser.Model.Querying; |
| | 7 | |
|
| | 8 | | namespace Emby.Server.Implementations.Sorting |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Class AlbumComparer. |
| | 12 | | /// </summary> |
| | 13 | | public class AlbumComparer : IBaseItemComparer |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Gets the name. |
| | 17 | | /// </summary> |
| | 18 | | /// <value>The name.</value> |
| 1 | 19 | | public ItemSortBy Type => ItemSortBy.Album; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Compares the specified x. |
| | 23 | | /// </summary> |
| | 24 | | /// <param name="x">The x.</param> |
| | 25 | | /// <param name="y">The y.</param> |
| | 26 | | /// <returns>System.Int32.</returns> |
| | 27 | | public int Compare(BaseItem? x, BaseItem? y) |
| | 28 | | { |
| 0 | 29 | | return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase); |
| | 30 | | } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Gets the value. |
| | 34 | | /// </summary> |
| | 35 | | /// <param name="x">The x.</param> |
| | 36 | | /// <returns>System.String.</returns> |
| | 37 | | private static string GetValue(BaseItem? x) |
| | 38 | | { |
| 0 | 39 | | return x is Audio audio ? audio.Album : string.Empty; |
| | 40 | | } |
| | 41 | | } |
| | 42 | | } |