Added sorting back into the input.