Changes message sort clauses for MySQL, fixes issue #961.