Sorting composite types

From: Miles Elam <miles(dot)elam(at)productops(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Sorting composite types
Date: 2019-08-06 18:23:04
Message-ID: CAALojA__7gN2PaonUTrSARS8PtVczfFoVP0pxjUYczk4HZGQ+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there any way to define a natural sorting order for composite types? For
example, let's say you have a type like:

CREATE TYPE contrived AS (
i1 integer,
i2 integer
);

The semantics of this contrived type are that the natural order is
ascending NULLS first for i1 and descending NULLS last for i2. I know I can
do an ORDER BY per query and specify each part separately, but if my
contrived example has a perceived natural sort order, is there any way to
set that in a global way so that I can simply and universally ORDER BY
my_contrived_column?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Llewellyn 2019-08-06 20:17:31 Why must AUTOCOMMIT be ON to do txn control in plpgsql procedure?
Previous Message Adrian Klaver 2019-08-06 18:01:01 Re: Does pgadmin4 work with postgresql 8.4?