What is the priority of characters when sorting in MySQL, PHP, or just generally?

Question: Where can I find the priority of characters when sorting in MySQL, PHP, or in general on Linux and Windows?

For example, everyone knows that a matches up to b when doing upward sorting on a string in MySQL. But what about other characters? A dollar sign $ appears in front of an asterisk * ? Does a space pass before an exclamation mark? etc...

What dictates the sort order? Does it use base ascii / UTF-8 values? Different different technologies?

Technologies to consider:

  • Databases - MySQL / SQL / SQLite / Oracle / etc
  • Programming languages ​​(for string sorting functions) - PHP / Javascript / ASP.NET / Visual C # / Python / Ruby / Objective C
  • OS (i.e. sorting files by file name) - Windows / Linux / MacOS / iOS / Android
+5
source share
4 answers
  • Databases - mappings if no integer character value mapping is specified
  • Programmable languages ​​- language or integer value of a character or user-defined function (usually all 3 options are available by default)
  • OS - Locale
+1
source

Symbols are represented as comparisons from an unsigned integer to a specific glyph. The specific mapping is determined by the character set.

, , , .

. Java String .

+1

In database terms, this is called a sort sequence, and most character sets have a default value. If you use Unicode, you can look here: http://www.unicode.org/reports/tr10/tr10-24.html

+1
source

This becomes even more interesting when considering other languages.

Ä and ö are letters with accents in Dutch and German, but the “real” letters are in the Swedish alphabet (after Z, and not between A and B / O and L, respectively).

+1
source

All Articles