List<Object> (@NotNull Map<Object, Integer> indices, @NotNull Iterable<Object> objects) { List<Object> list = new ArrayList<>(indices.size()); int last = -1; for (Object object : objects) { Integer index = indices.get(object); if (index != null && last < index.intValue()) { last = index; list.add(object); } } return list; }