I believe that I figured it out.
I was using dashes in my query parameter names and I should have been using underscores instead. For example, "shipping-interval" instead of "shipping_interval". When these parameters were being sorted, Shopify was sorting the keys one way, while the PHP function ksort was sorting slightly differently. I had a few parameters named similarly - "shipping-interval" and "shipping-interval-day", for example and they were sorted differently between the two systems.
Converting the parameter names to use underscores instead of dashes seems to have resolved the problem.