Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make fields sorted by lexicographical order #7711

Merged
merged 13 commits into from
May 8, 2021
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the XMP Importer would incorrectly return an empty default entry when importing pdfs [#6577](https://github.com/JabRef/jabref/issues/6577)
- We fixed an issue where opening the menu 'Library properties' marked the library as modified [#6451](https://github.com/JabRef/jabref/issues/6451)
- We fixed an issue when importing resulted in an exception [#7343](https://github.com/JabRef/jabref/issues/7343)

- We fixed an issue Some fields are in random order [#7710](https://github.com/JabRef/jabref/issues/7710)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- We fixed an issue Some fields are in random order [#7710](https://github.com/JabRef/jabref/issues/7710)
- We fixed an issue where the field in the Field formatter dropdown selection were sorted in random order [#7710](https://github.com/JabRef/jabref/issues/7710)

### Removed

- The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group.
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/jabref/model/entry/field/FieldFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.TreeSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
Expand Down Expand Up @@ -100,7 +101,12 @@ public static Set<Field> getJournalNameFields() {
public static Set<Field> getCommonFields() {
EnumSet<StandardField> allFields = EnumSet.allOf(StandardField.class);

LinkedHashSet<Field> publicAndInternalFields = new LinkedHashSet<>(allFields.size() + 3);
TreeSet<Field> publicAndInternalFields = new TreeSet<>((field1, field2) -> {
if (field1.getDisplayName().equals(field2.getDisplayName()))
return 0;
return field1.getDisplayName().compareTo(field2.getDisplayName()) > 0 ? 1 : -1;
}
);
publicAndInternalFields.add(InternalField.INTERNAL_ALL_FIELD);
publicAndInternalFields.add(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD);
publicAndInternalFields.add(InternalField.KEY_FIELD);
Expand Down