Sorting functionality, both ascending and descending.