public static void sortMessages(Message[] messages, final SortTerm[] sortTerm) {
        final List<SortTermWithDescending> sortTermsWithDescending = getSortTermsWithDescending(sortTerm);
        sortMessages(messages, sortTermsWithDescending);
    }
@Test
    public void testSortMessagesWithTie() {
        Message[] given = new Message[] { MESSAGES[2], TIE_BREAKER };

        // Sort according to the whole list. Only the last element breaks the tie
        Message[] actual1 = given.clone();
        MailSorter.sortMessages(actual1, POSSIBLE_TERMS);
        assertArrayEquals(actual1, new Message[] { TIE_BREAKER, MESSAGES[2] });

        // now reverse the last element (the tie breaker)
        SortTerm[] reversed = new SortTerm[POSSIBLE_TERMS.length + 1];
        System.arraycopy(POSSIBLE_TERMS, 0, reversed, 0, POSSIBLE_TERMS.length - 1);
        reversed[reversed.length - 2] = SortTerm.REVERSE;
        reversed[reversed.length - 1] = POSSIBLE_TERMS[POSSIBLE_TERMS.length - 1];
        // And check again
        Message[] actual2 = given.clone();
        MailSorter.sortMessages(actual2, reversed);
        assertArrayEquals(actual2, new Message[] { MESSAGES[2], TIE_BREAKER });
    }