@Override
    protected void descendingSort(File[] matchingFileArray, Instant instant) {

        String regexForIndexExtreaction = createStemRegex(instant);
        final Pattern pattern = Pattern.compile(regexForIndexExtreaction);

        Arrays.sort(matchingFileArray, new Comparator<File>() {
            @Override
            public int compare(final File f1, final File f2) {

                int index1 = extractIndex(pattern, f1);
                int index2 = extractIndex(pattern, f2);

                if (index1 == index2)
                    return 0;
                // descending sort, i.e. newest files first
                if (index2 < index1)
                    return -1;
                else
                    return 1;
            }

            private int extractIndex(Pattern pattern, File f1) {
                Matcher matcher = pattern.matcher(f1.getName());
                if (matcher.find()) {
                    String indexAsStr = matcher.group(1);

                    if (indexAsStr == null || indexAsStr.isEmpty())
                        return NO_INDEX; // unreachable code?
                    else
                        return Integer.parseInt(indexAsStr);
                } else
                    return NO_INDEX;
            }
        });
    }
@Test
    public void badFilenames() {
        FileNamePattern fileNamePattern = new FileNamePattern("smoke-%d-%i.gz", context);
        SizeAndTimeBasedArchiveRemover remover = new SizeAndTimeBasedArchiveRemover(fileNamePattern, null);
        File[] fileArray = new File[2];
        File[] expected = new File[2];

        fileArray[0] = expected[0] = new File("/tmp/smoke-1970-01-01-b.gz");
        fileArray[1] = expected[1] = new File("/tmp/smoke-1970-01-01-c.gz");

        remover.descendingSort(fileArray, Instant.ofEpochMilli(0));

        assertArrayEquals(expected, fileArray);
    }