Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1viT12-0077P1-0F for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 07:52:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1viT11-005cSF-0l for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 07:52:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1viT10-005cRe-09 for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 07:52:35 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1viT0w-001gAP-2j for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 07:52:34 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id B83171D0005F; Wed, 21 Jan 2026 02:52:27 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 21 Jan 2026 02:52:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1768981947; x=1769068347; bh=QOQ781vPyPCQSKNDhRleNPNrL+SPgUC/KuCU52cd3k4=; b= HGU9qjEubNC9uPJ30HfpwJd+AgdGwApTQ037GfPL6pKdwdpth9Hn45hztN12pM8W 3/ZIb9M4QxYNT/3gIvX7aL+E+U+vimHS6Q+c15Jka+3WobjNKHNQ3ejU4+mBL24c 13qs6tF3FVzkjYA683DJseIB6ctYFh1mR4djqjLnAB9rgo0J+ZE+fVtPfd/1d0J9 6XZjU/aCENKrrDAadTpGVb31TL5OImS97ElNclDosU4P9q+NYF3TsciFwa8bsksU NlIqjotefTkA6vM9rNXuW9rlbWTDsYxiAHYGLPfeNMLIjVBUIr/4N5TPwb3zxp9O OOOwRIoP8d5nJrrcOl7bvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1768981947; x=1769068347; bh=Q OQ781vPyPCQSKNDhRleNPNrL+SPgUC/KuCU52cd3k4=; b=NCxEI67sVw3i0Ek/o Z3Y7vOv99h4+Tf6mdN8raTNs6Ppox+Rhvt5p9ueOiD5bUDCcve6okXOWngdhikdg sWkqKC6o/RNvajmf6ITGfST+Dv+C5Aaj3Rx61T1yI6lAtgiwLYgMvWmcfCJTWuqP 8DvNqzscRU0o7hbMMZAPNJaNyq2damC1i2XP5Gf5NQX/1RVJ2JTQPPFkd3twEw/M U0sH3da+HEHITRLjvP8UCxPDEgpeAn6NOnODiMLMf4zvdbZbiuF875pdy+OSomea 4Ov5/vjrUnGqW3/GBI3nuS0QL1MC5OarEPtahG8xbcVPaUvl9NdAK0zmy+3DMJMh aN2cg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugedvjedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegv ihhsvghnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepudfgjefffeelfedvge dvjedvieehvefghfejgfduhfevvdejveefheetlefgveefnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruh htrdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphht thhopehpohhsthhgrhgvshhqlhdrohhrghesmhhsqhhrrdhushdprhgtphhtthhopehpgh hsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Jan 2026 02:52:26 -0500 (EST) Message-ID: <03f1450c-a730-40af-890c-c269db74a8ec@eisentraut.org> Date: Wed, 21 Jan 2026 08:52:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Collation with upper and numeric comparing in unexpected way To: Matt Magoffin , pgsql-general@lists.postgresql.org References: <9EBA273E-7F3C-40F4-8156-745A4BB5B090@msqr.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <9EBA273E-7F3C-40F4-8156-745A4BB5B090@msqr.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 20.01.26 19:36, Matt Magoffin wrote: > I am using Postgres 17 and trying to configure a collation that sorts upper case before lower case and includes numeric sorting: > > CREATE COLLATION testsort (provider = icu, locale = 'und-u-kf-upper-kn’); > > These comparisons are working as I expected: > > SELECT 'id-45' < 'id-123' COLLATE testsort; -- true (45 before 123) > > SELECT 'id' < 'ID' COLLATE testsort; -- false (upper case before lower case) > > However combining them resulted in an unexpected result: > > SELECT 'id-45' < 'ID-123' COLLATE testsort; -- true > > I thought that last one would be false because “ID” would come before “id”. Is there a way to configure the collation to achieve that? I’m trying to match the sorting behaviour in external application code. I suspect that this is because the effect of the numeric sorting is a primary difference and the case difference is only a tertiary difference. In other words, imagine the numeric sorting pass replacing all numbers by hypothetical letters corresponding to the numeric order, like 'id-45' -> 'id-X' 'id-123' -> 'id-Z' 'ID-123' -> 'ID-Z' Then you would have 'id-45' < 'ID-123' => 'id-X' < 'ID-Z' which would be correct. This is just my guess from the outside. The numeric sorting is not a part of the Unicode Collation Algorithm standard, it is an extension by ICU, so one would have to dig into the code or documentation there, but I didn't find anything. I don't know if there is a way to customize this further to get the effect you want. Maybe you could reach out to an ICU support forum to get more expert insights there.