Re: ORDER BY elements in ARRAY

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Andreas Joseph Krogh <andreas(at)visena(dot)com>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: ORDER BY elements in ARRAY
Date: 2024-08-27 16:03:37
Message-ID: CAKFQuwZRaJ4AHNQZgs6pNru_WGm5MOjH+mHa3dWELNS=N_4j6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tuesday, August 27, 2024, Andreas Joseph Krogh <andreas(at)visena(dot)com>
wrote:

> På tirsdag 27. august 2024 kl. 14:39:34, skrev David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com>:
>
> […]
> Add order by here
>
>> ) as person_array
>>
>> FROM onp_crm_relation comp
>> ORDER BY person_array
>> ;
>>
>>
> David J.
>
>
>
> This doesn't really do it. I'm looking for something analogous to Java's
> Comparator-interface so the custom datatype knows how to sort itself.
>

Ah. Then either just put those two values into the first two field
positions of your custom type and live with an easy, but also
self-contained, hack, or figure out what incantations of create operator
and/or create operator family are need to install custom behavior for the
b-tree < and > operators. I’m 80% sure it’s doable, 60% in plpgsql…

David J.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Bernitt 2024-08-27 16:05:00 Re: object mapping for json/jsonb columns
Previous Message Steve Midgley 2024-08-27 15:34:55 Re: object mapping for json/jsonb columns