CommunityRatingComparer.cs 951 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma warning disable CS1591
  2. using System;
  3. using Jellyfin.Data.Enums;
  4. using MediaBrowser.Controller.Entities;
  5. using MediaBrowser.Controller.Sorting;
  6. using MediaBrowser.Model.Querying;
  7. namespace Emby.Server.Implementations.Sorting
  8. {
  9. public class CommunityRatingComparer : IBaseItemComparer
  10. {
  11. /// <summary>
  12. /// Gets the name.
  13. /// </summary>
  14. /// <value>The name.</value>
  15. public ItemSortBy Type => ItemSortBy.CommunityRating;
  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. ArgumentNullException.ThrowIfNull(x);
  25. ArgumentNullException.ThrowIfNull(y);
  26. return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);
  27. }
  28. }
  29. }