Skip to content

Commit

Permalink
Sort bibliography suggestions by label
Browse files Browse the repository at this point in the history
  • Loading branch information
khoidt committed Jun 12, 2023
1 parent f3775ae commit d97453d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bibliography/ui/BibliographySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
})
}
Expand Down

0 comments on commit d97453d

Please sign in to comment.