added some functionality to commandSort