Skip to content

Instantly share code, notes, and snippets.

@HelgeSverre
Last active March 21, 2020 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HelgeSverre/00a4fc197d673cb6283b0b3205e29755 to your computer and use it in GitHub Desktop.
Save HelgeSverre/00a4fc197d673cb6283b0b3205e29755 to your computer and use it in GitHub Desktop.
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