Problem: On the Search results page you have the Search Action Links to display the sort options. Whenever you click on the field to sort on it gives you a Javascript.
Resolution: Make sure your Search box is on the Search Results page.
If you have customized Master Page make sure that you are displaying the Search box. Even if it is hidden you will get the Javascript error. If it is deleted please insert the web part back on the page.
Not sure how the sort by is tied with Search Box web part. 🙂