use of org.jabref.logic.bibtex.comparator.IdComparator in project jabref by JabRef.
the class BibDatabaseWriter method getSaveComparators.
private static List<Comparator<BibEntry>> getSaveComparators(SavePreferences preferences, MetaData metaData) {
List<Comparator<BibEntry>> comparators = new ArrayList<>();
Optional<SaveOrderConfig> saveOrder = getSaveOrder(preferences, metaData);
// Take care, using CrossRefEntry-Comparator, that referred entries occur after referring
// ones. This is a necessary requirement for BibTeX to be able to resolve referenced entries correctly.
comparators.add(new CrossRefEntryComparator());
if (!saveOrder.isPresent()) {
// entries will be sorted based on their internal IDs
comparators.add(new IdComparator());
} else {
// use configured sorting strategy
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[0]));
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[1]));
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[2]));
comparators.add(new FieldComparator(BibEntry.KEY_FIELD));
}
return comparators;
}
Aggregations