Finalized the sort functionality for the tables

reverse sort now works as well