sort function using sort