fix sorting and shell output