(premature) optimization: only sort the messages if they are out of order to begin with