diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index d7ccfd8aee..abd1a2a543 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -112,37 +112,35 @@ namespace MediaBrowser.Controller.Entities.Movies return true; } - public override List GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query) + public IEnumerable Sort(IEnumerable items, User user) { - var children = base.GetChildren(user, includeLinkedChildren, query); - - if (string.Equals(DisplayOrder, "SortName", StringComparison.OrdinalIgnoreCase)) + var sortBy = new[] { - // Sort by name - return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList(); - } - - if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase)) + ItemSortBy.ProductionYear, + ItemSortBy.PremiereDate, + ItemSortBy.SortName + }; + if (!string.IsNullOrEmpty(DisplayOrder)) { - // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); + sortBy = new[] + { + Enum.Parse(DisplayOrder) + }; } - // Default sorting - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); + return LibraryManager.Sort(items, user, sortBy, SortOrder.Ascending); + } + + public override List GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query) + { + var children = base.GetChildren(user, includeLinkedChildren, query); + return Sort(children, user).ToList(); } public override IEnumerable GetRecursiveChildren(User user, InternalItemsQuery query) { var children = base.GetRecursiveChildren(user, query); - - if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase)) - { - // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); - } - - return children; + return Sort(children, user).ToList(); } public BoxSetInfo GetLookupInfo()