diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f4dda149d5d..a327258986f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where it was hard to distinguish between enabled/disabled status of search buttons in dark mode and added tooltips. [#11569](https://github.com/JabRef/jabref/issues/11569) - We fixed an issue where entries containing dollar signs, backslashes, or unset fields passed to `substring$` caused citation style preview and export to fail. [#12799](https://github.com/JabRef/jabref/issues/12799) +- We fixed an issue where citationcount, day, and dayfiled columns were sorted alphabetically instead of numerically. [#17459](https://github.com/JabRef/jabref/issues/17459) - We fixed exports to RIS, CSV, HTML, and other template-based formats in native JabKit. [#17408](https://github.com/JabRef/jabref/issues/17408) - We fixed JabKit to preserve existing citation keys when generating keys with the avoid-overwrite setting. [#17458](https://github.com/JabRef/jabref/issues/17458) - We fixed an issue where JabRef showed an "Executor has been shut down" error on Windows after resuming from suspend. [#17144](https://github.com/JabRef/jabref/pull/17144) diff --git a/jabgui/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java b/jabgui/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java index 8cfebc135dae..971b31528d35 100644 --- a/jabgui/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java +++ b/jabgui/src/test/java/org/jabref/gui/util/comparator/NumericFieldComparatorTest.java @@ -1,5 +1,7 @@ package org.jabref.gui.util.comparator; +import java.util.List; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,6 +45,13 @@ void compareIntegerWithString() { assertEquals(1, comparator.compare("4", "hi")); } + @Test + void sortMixedTextAndNumericValues() { + List values = List.of("Wednesday", "10", "Tuesday", "2"); + + assertEquals(List.of("Tuesday", "Wednesday", "2", "10"), values.stream().sorted(comparator).toList()); + } + @Test void compareNegativeInteger() { assertEquals(1, comparator.compare("-4", "-5")); diff --git a/jablib/src/main/java/org/jabref/model/entry/field/FieldProperty.java b/jablib/src/main/java/org/jabref/model/entry/field/FieldProperty.java index cf329e2d4d61..b8588ae50a5c 100644 --- a/jablib/src/main/java/org/jabref/model/entry/field/FieldProperty.java +++ b/jablib/src/main/java/org/jabref/model/entry/field/FieldProperty.java @@ -24,6 +24,11 @@ public enum FieldProperty { MONTH, MULTILINE_TEXT, + + /// Enables numeric-aware sorting and causes JabRef to treat the field as non-LaTeX content. + /// This is a JabRef property, not a BibLaTeX datatype: `edition` accepts integers or + /// literal values, and `number` and `pagetotal` are literal fields. See the [BibLaTeX + /// manual, section 2.2.2](https://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf). NUMERIC, PAGINATION, PERSON_NAMES, diff --git a/jablib/src/main/java/org/jabref/model/entry/field/StandardField.java b/jablib/src/main/java/org/jabref/model/entry/field/StandardField.java index 4a18b8f214a1..726bb986ae9f 100644 --- a/jablib/src/main/java/org/jabref/model/entry/field/StandardField.java +++ b/jablib/src/main/java/org/jabref/model/entry/field/StandardField.java @@ -33,8 +33,8 @@ public enum StandardField implements Field { CROSSREF("crossref", FieldProperty.SINGLE_ENTRY_LINK), CITES("cites", FieldProperty.MULTIPLE_ENTRY_LINK), DATE("date", FieldProperty.DATE), - DAY("day"), - DAYFILED("dayfiled"), + DAY("day", FieldProperty.NUMERIC), + DAYFILED("dayfiled", FieldProperty.NUMERIC), DOI("doi", FieldProperty.VERBATIM, FieldProperty.IDENTIFIER), EDITION("edition", FieldProperty.NUMERIC), EDITOR("editor", FieldProperty.PERSON_NAMES), @@ -144,7 +144,7 @@ public enum StandardField implements Field { // region: JabRef-specific fields - CITATIONCOUNT("citationcount"), + CITATIONCOUNT("citationcount", FieldProperty.NUMERIC), GROUPS("groups"), ICORERANKING("icore"), OWNER("owner"), diff --git a/jablib/src/test/java/org/jabref/model/entry/field/StandardFieldTest.java b/jablib/src/test/java/org/jabref/model/entry/field/StandardFieldTest.java index 4ea68752d792..f02899b21367 100644 --- a/jablib/src/test/java/org/jabref/model/entry/field/StandardFieldTest.java +++ b/jablib/src/test/java/org/jabref/model/entry/field/StandardFieldTest.java @@ -3,6 +3,8 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; class StandardFieldTest { @@ -10,4 +12,17 @@ class StandardFieldTest { void fieldsConsideredEqualIfSame() { assertEquals(StandardField.TITLE, StandardField.TITLE); } + + @Test + void numericFieldsHaveNumericProperty() { + assertTrue(StandardField.CITATIONCOUNT.isNumeric()); + assertTrue(StandardField.DAY.isNumeric()); + assertTrue(StandardField.DAYFILED.isNumeric()); + } + + @Test + void nonNumericFieldsDoNotHaveNumericProperty() { + assertFalse(StandardField.CHAPTER.isNumeric()); + assertFalse(StandardField.PART.isNumeric()); + } }