IDocumentSearchService.get does not return sorted list

How is it possible to get the result of IDocumentSearchService.get sorted?

Is there already a Comparator implemented?

You have to implement it yourself.

private static final Comparator<IEntityInstance> EntityInstanceComparator = (a, b) -> {
	final int[] repetitionsA = a.getRepetitions();
	final int[] repetitionsB = b.getRepetitions();

	for (int i = 0; i < repetitionsA.length && i < repetitionsB.length; i++) {
		final int delta = repetitionsA[i] - repetitionsB[i];
		if (delta != 0) {
			return delta;
		}
	}
	// both are equal up to the length of the shorter one
	// -> if the lengths are the same, they are fully equal -> return 0
	// -> if the lengths differ, the shorter one counts as 'smaller'
	return repetitionsA.length - repetitionsB.length;
};