rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.27k stars 180 forks source link

group sort order #416

Closed andreasnuesslein closed 2 years ago

andreasnuesslein commented 2 years ago

if anybody else is looking for this:

the ordering of the groups is influenced by the order of the actual items of the list, rather than the names of the groups.

however: groupFilter can be used to define the order of the groups as well.

e.g.:

      groupBy={(c) => (["DE", "AT", "CH"].includes(c.code) ? "dach" : "")}
      groupFilter={() => ["dach", ""]}

this way the "dach" comes first, eventhough in the country list (due to Afghanistan) the "" group would usually come first.