Swedish Alphabetical Sort

Sort with å, ä, ö at the END of the alphabet (after z)

Sorts a list using Swedish collation, which places å, ä and ö after z at the end of the alphabet — the critical difference from German umlaut ordering and from a naive byte sort. Runs locally in your browser.

How does Swedish sort order differ from English?

Swedish has a 29-letter alphabet that ends with å, ä and ö after z. So in a Swedish sort, Älvsjö and Örebro come after every word starting with a–z, not near the start with the other a and o words.

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

  1. Split into items. Your input is divided into lines, and blank lines are dropped.
  2. Swedish collation. Each pair of items is compared with the browser’s Intl.Collator set to the sv locale. This implements the official Swedish ordering, where the base alphabet runs a–z and then continues å, ä, ö.
  3. 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.