comparison and sort functionality separated