Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the precedence of characters when sorting in MySQL, PHP, or just in general?

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

For example, everybody knows that a comes before b when performing an ascending sort on a string in MySQL. But what about other characters? Does the dollar-sign $ come before asterisk * ? Does a space come before an exclamation-mark? etc...

What dictates the sort order? Does it use underlying ascii / UTF-8 values? Is it different for different technologies?

Technologies to consider:

  1. Databases - MySQL / SQL / SQLite / Oracle / etc
  2. Programming languages (for string-sorting functions) - PHP / Javascript / ASP.NET / Visual C# / Python / Ruby / Objective C
  3. OS (i.e., sorting files by filename) - Windows / Linux / MacOS / iOS / Android
like image 620
JoshuaDavid Avatar asked Oct 07 '22 14:10

JoshuaDavid


1 Answers

  1. Databases - collations, if no collation is set integer character value
  2. Programing languages - locale or integer character value or user defined function (usually all 3 options are available by default)
  3. OS - Locale
like image 120
c2h5oh Avatar answered Oct 10 '22 09:10

c2h5oh