improve sort function ...