Handled some problems with sort input.