As suspected, the instructions from those two threads have been shared for two different use cases or requirements, but they can't be used together, I'm afraid.
The script blocks the autoloading for infinite scroll but that also stops the reset function that triggers when the sorting order is changed from the front-end.
Based on what we have discussed, you can go with these workarounds:
1. If you need to show the list of products with front-end sorting controls, it would be better to use regular pagination where the results of other pages disappear, rather than the infinite scroll in which the previous results stay.
I recall that you're using this on the home page, as product slider, so this change shouldn't bring in any major visual or usability difference.
2. If you'd like to keep the previous page results and front-end sorting, you can disable infinite scrolling and switch to regular pagination. Then using complex custom CSS and JS code, you can hide the actual list of view's results and maintain a shadow list on the page, in which new results are appended programmatically as they become available through pagination.