Re: sorting/comparing column values in non-alphanumeric sorting ways ?

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: David Gauthier <davegauthierpg(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: sorting/comparing column values in non-alphanumeric sorting ways ?
Date: 2018-07-11 22:06:27
Message-ID: CAH2-WzmvqV-u6X1LoX2V=qVhCx7Xr9mVYo0qjZcE_GkJpJgA-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 11, 2018 at 2:44 PM, David Gauthier
<davegauthierpg(at)gmail(dot)com> wrote:
> I want to load the 'highestver' column with the highest version of tcfg1-3.
>
> This won't work...
> update tv set greatest = greatest(tcfg1,tcfg2,tcfg3)
> ...because it thinks 1.0.9 is greater than 1.0.10
>
> Is there a way to get this to work right ?

If you're using v10 with ICU, then you can create a custom ICU
collation for this, with "natural" sort order. Something like this
should work:

CREATE COLLATION numeric (provider = icu, locale = 'en-u-kn-true');

See the docs -- "23.2.2.3.2. ICU collations".

--
Peter Geoghegan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Cross 2018-07-11 22:20:13 Re: Open Source tool to deploy/promote PostgreSQL DDL
Previous Message David G. Johnston 2018-07-11 21:50:21 Re: sorting/comparing column values in non-alphanumeric sorting ways ?