create sort function

fix