sorting input commands