StudioComparer.cs 1.1 KB

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