2
0

CriticRatingComparer.cs 959 B

1234567891011121314151617181920212223242526272829303132333435
  1. using Jellyfin.Data.Enums;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Controller.Sorting;
  4. using MediaBrowser.Model.Querying;
  5. namespace Emby.Server.Implementations.Sorting
  6. {
  7. /// <summary>
  8. /// Class CriticRatingComparer.
  9. /// </summary>
  10. public class CriticRatingComparer : IBaseItemComparer
  11. {
  12. /// <summary>
  13. /// Gets the name.
  14. /// </summary>
  15. /// <value>The name.</value>
  16. public ItemSortBy Type => ItemSortBy.CriticRating;
  17. /// <summary>
  18. /// Compares the specified x.
  19. /// </summary>
  20. /// <param name="x">The x.</param>
  21. /// <param name="y">The y.</param>
  22. /// <returns>System.Int32.</returns>
  23. public int Compare(BaseItem? x, BaseItem? y)
  24. {
  25. return GetValue(x).CompareTo(GetValue(y));
  26. }
  27. private static float GetValue(BaseItem? x)
  28. {
  29. return x?.CriticRating ?? 0;
  30. }
  31. }
  32. }