Added code for sorting by rating.