The Swedish Alphabetical Sort orders a list the way Swedish actually does, with å, ä and ö placed after z at the very end of the 29-letter alphabet. Getting this wrong is one of the most common localisation bugs, because a default byte sort or a German-style sort puts those letters in the wrong place.
How it works
- Split into items. Your input is divided into lines, and blank lines are dropped.
- Swedish collation. Each pair of items is compared with the browser’s
Intl.Collatorset to thesvlocale. This implements the official Swedish ordering, where the base alphabet runs a–z and then continues å, ä, ö. - Direction. The result is shown ascending by default; ticking descending reverses it so the å/ä/ö words appear first.
Why this matters
Consider sorting these cities: Örebro, Åmål, Stockholm, Älvsjö, Zinkgruvan. In Swedish the correct order is:
Stockholm
Uppsala
Zinkgruvan
Åmål
Älvsjö
Örebro
A naive sort would scatter Åmål, Älvsjö and Örebro near the A and O entries, which is wrong for Swedish readers and indexes. German would do the same. Only Swedish collation pushes them to the end.
Notes
The sort uses base sensitivity, so it ignores letter case while preserving the distinct end-of-alphabet positions of å, ä and ö. Numbers and punctuation sort before letters.