From d97453da308fa2668dad656c6e7457c3c2d4d1b8 Mon Sep 17 00:00:00 2001 From: Ilya Khait Date: Mon, 12 Jun 2023 10:35:14 +0000 Subject: [PATCH] Sort bibliography suggestions by label --- src/bibliography/ui/BibliographySelect.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bibliography/ui/BibliographySelect.tsx b/src/bibliography/ui/BibliographySelect.tsx index 547cf8a25..45a186ffc 100644 --- a/src/bibliography/ui/BibliographySelect.tsx +++ b/src/bibliography/ui/BibliographySelect.tsx @@ -40,6 +40,9 @@ interface Props { onChange: (event: BibliographyEntry) => void isClearable: boolean } + +const collator = new Intl.Collator([], { numeric: true }) + export default function BibliographySelect({ ariaLabel, value, @@ -66,6 +69,7 @@ export default function BibliographySelect({ const options = entries .map(createOption) .filter((option) => option !== null) as SelectedOption[] + options.sort((a, b) => collator.compare(a.label, b.label)) callback(options) }) }