Implemented sorting in for the table view.