implemented sort by on the back end