adding the sort function