Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMCvq-0002l2-Su for pgsql-general@arkaria.postgresql.org; Wed, 08 Apr 2020 15:48:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMCvp-0000TZ-Pz for pgsql-general@arkaria.postgresql.org; Wed, 08 Apr 2020 15:48:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMCvp-0000Pg-I7 for pgsql-general@lists.postgresql.org; Wed, 08 Apr 2020 15:48:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMCvj-0002Op-0V for pgsql-general@postgresql.org; Wed, 08 Apr 2020 15:48:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 038Flpxu030447; Wed, 8 Apr 2020 11:47:51 -0400 From: Tom Lane To: "Jimmy Thrasher" cc: pgsql-general@postgresql.org Subject: Re: Unexpected behavior sorting strings In-reply-to: <410dddd6-bc66-48ca-ab9d-13889d94b62c@www.fastmail.com> References: <410dddd6-bc66-48ca-ab9d-13889d94b62c@www.fastmail.com> Comments: In-reply-to "Jimmy Thrasher" message dated "Wed, 08 Apr 2020 10:35:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30445.1586360871.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Apr 2020 11:47:51 -0400 Message-ID: <30446.1586360871@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Jimmy Thrasher" writes: > As I understand it, postgresql sorts strings roughly like strcmp does: c= haracter by character based on encoding value. Only if you're using C locale. Other locales such as en_US have completely different rules, which most hackers tend to find pretty unintelligible and inconsistent :-(. In your example, I think the first-pass sort is on just the letters, and only if those are the same will it consider the punctuation. regards, tom lane