2
0

SortNameComparer.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Sorting;
  3. using MediaBrowser.Model.Querying;
  4. using System;
  5. namespace MediaBrowser.Server.Implementations.Sorting
  6. {
  7. /// <summary>
  8. /// Class SortNameComparer
  9. /// </summary>
  10. public class SortNameComparer : 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.EnableAlphaNumericSorting || !y.EnableAlphaNumericSorting)
  21. {
  22. return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
  23. }
  24. return AlphanumComparator.CompareValues(x.SortName, y.SortName);
  25. }
  26. /// <summary>
  27. /// Gets the name.
  28. /// </summary>
  29. /// <value>The name.</value>
  30. public string Name
  31. {
  32. get { return ItemSortBy.SortName; }
  33. }
  34. }
  35. }