CriticRatingComparer.cs 928 B

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