Manage sort by direction from controller; Minor code cleanup