PostgreSQL and its way of sorting strings

Updated . Posted . Visible to the public. Repeats.

PostgreSQL uses the C library's locale facilities for sorting strings:

  • First, all the letters are compared, ignoring spaces and punctuation.
  • It sorts upper and lower case letters together. So the order will be something like a A b B c C
  • Then, spaces and punctuation are compared to break ties.

Example:

Ruby PostgreSQL
IMAGE3.jpg image2.jpg
image.jpg image3.jpg
image2.jpg IMAGE3.jpg
image3.jpg image.jpg

Further reading

Natalie Zeumann
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Natalie Zeumann to makandra dev (2016-06-29 08:01)