Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to make sorting work properly for Norwegian characters in MySQL - Æ Ø Å

If you have an issue with "order by " not working correctly with norwegian characters eg:

table: names

  • Andreas
  • Betty
  • Øystein
  • Ole martin
  • Ylvis
  • Åse Hansen

SELECT * FROM names ORDER BY name ASC, this will become something like:

  • Andreas
  • Åse Hansen
  • Betty
  • Ole martin
  • Øystein
  • Ylvis

because mysql sees ø as o, å as a etc To fix this, change your collation to utf8mb4_swedish_ci Like this:

ALTER TABLE YOUR-TABLE-NAME-HERE CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_swedish_ci;

Stuff will now be correctly sorted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment