diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index 59cb8ea2c..cd1e31e80 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -40,10 +40,12 @@ namespace Jellyfin.Api.Helpers result[i] = (sortBy[i], requestedSortOrder[i]); } - // Add remaining elements with the default SortOrder + // Add remaining elements with the first specified SortOrder + // or the default one if no SortOrders are specified + var order = requestedSortOrder.Count > 0 ? requestedSortOrder[0] : SortOrder.Ascending; for (; i < sortBy.Count; i++) { - result[i] = (sortBy[i], SortOrder.Ascending); + result[i] = (sortBy[i], order); } return result; diff --git a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs index 944472c68..606041c7f 100644 --- a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs +++ b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs @@ -51,7 +51,7 @@ namespace Jellyfin.Api.Tests.Helpers new (string, SortOrder)[] { ("SortName", SortOrder.Descending), - ("ProductionYear", SortOrder.Ascending), + ("ProductionYear", SortOrder.Descending), } }; }