small changes to sort