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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class FieldFormatterCleanupsPanelViewModel {
private final ObjectProperty<Formatter> selectedFormatterProperty = new SimpleObjectProperty<>();

public FieldFormatterCleanupsPanelViewModel() {
availableFieldsProperty.sort((field1, field2) -> {
if (field1.getDisplayName().equals(field2.getDisplayName())) {
Copy link
Member

Choose a reason for hiding this comment

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

The compareTo already performs equal checks...
So you should be able to directly use sort(field1, field2) -> field1.getDisplayName().compareTo(field2.getDisplayName))

Choose a reason for hiding this comment

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

Comparator.comparing should work as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What you said really makes sense and I have modified them.

return 0;
}
return field1.getDisplayName().compareTo(field2.getDisplayName()) > 0 ? 1 : -1;
});
}

public void resetToRecommended() {
Expand Down