Updated sort function and added a new command.