Sorting by with multiple filter options

Hello,
I am trying to merge storefront filtering and sorting in my custom theme collections page.

Both things work, but the ‘sort_by’ parameters are overwriting the filtering ones when these are multiple.

i.e of how the URL should look once filtering with two parameters (sizes XXS and XL) and sorting by ascending price:
../collections/new-arrivals?filter.v.option.size=XXS&filter.v.option.size=XL&sort_by=price-ascending

But this is what happens when sorting:
../collections/new-arrivals?filter.v.option.size=XXS&sort_by=price-ascending

Second filtering parameter gets overwritten by the sorting one.

Pasting below my code for the JS piece that triggers the sorting behaviour.

// sortby
$(function() {
Shopify.queryParams = {};
if(location.search.length) {
for(var aKeyValue, i = 0, aCouples = location.search.substr(1).split('&'); i < aCouples.length; i++) {
aKeyValue = aCouples[i].split('=');
if (aKeyValue.length > 1) {
Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]);
}
}
}

document.querySelector('.sort-by').addEventListener('change', function(e) {
var value = e.currentTarget.value;
Shopify.queryParams.sort_by = value;
location.search = new URLSearchParams(Shopify.queryParams).toString();
});
})

Has someone ever tried to achieve something like this?
I would appreciate any help.

Thanks in advance,