- fixed sort function