StudioComparer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Linq;
  5. using Jellyfin.Extensions;
  6. using MediaBrowser.Controller.Entities;
  7. using MediaBrowser.Controller.Sorting;
  8. using MediaBrowser.Model.Querying;
  9. namespace Emby.Server.Implementations.Sorting
  10. {
  11. public class StudioComparer : IBaseItemComparer
  12. {
  13. /// <summary>
  14. /// Compares the specified x.
  15. /// </summary>
  16. /// <param name="x">The x.</param>
  17. /// <param name="y">The y.</param>
  18. /// <returns>System.Int32.</returns>
  19. public int Compare(BaseItem x, BaseItem y)
  20. {
  21. if (x == null)
  22. {
  23. throw new ArgumentNullException(nameof(x));
  24. }
  25. if (y == null)
  26. {
  27. throw new ArgumentNullException(nameof(y));
  28. }
  29. return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());
  30. }
  31. /// <summary>
  32. /// Gets the name.
  33. /// </summary>
  34. /// <value>The name.</value>
  35. public string Name => ItemSortBy.Studio;
  36. }
  37. }