@Override
    public int compare(String indexName1, String indexName2) {
        int separatorPosition = indexName1.lastIndexOf(separator);
        int index1Number;
        final String indexPrefix1 = separatorPosition != -1 ? indexName1.substring(0, separatorPosition) : indexName1;
        try {
            index1Number = Integer.parseInt(indexName1.substring(separatorPosition + 1));
        } catch (Exception e) {
            index1Number = Integer.MIN_VALUE; //wrongly formatted index names go last
        }

        separatorPosition = indexName2.lastIndexOf(separator);
        int index2Number;
        final String indexPrefix2 = separatorPosition != -1 ? indexName2.substring(0, separatorPosition) : indexName2;
        try {
            index2Number = Integer.parseInt(indexName2.substring(separatorPosition + 1));
        } catch (NumberFormatException e) {
            index2Number = Integer.MIN_VALUE; //wrongly formatted index names go last
        }

        final int prefixComparisonResult = indexPrefix1.compareTo(indexPrefix2);
        if (prefixComparisonResult == 0) {
            return -Integer.compare(index1Number, index2Number);
        } else {
            return prefixComparisonResult;
        }
    }
@Test
    void comparesDescByNumberAfterLastSeparatorOccurrence() {
        assertTrue(comparator.compare("lalala_5", "lalala_3") < 0);
        assertTrue(comparator.compare("lalala_3", "lalala_5") > 0);

        assertTrue(comparator.compare("lalala_1_5", "lalala_1_3") < 0);
        assertTrue(comparator.compare("lalala_1_5", "lalala_1_0") < 0);
    }