The function of sort