Finish first sort function