fixed sort routine