sort the inputs