Re: Custom sorting - Mailing list pgsql-novice

From Tom Lane
Subject Re: Custom sorting
Date
Msg-id 4779.1242501363@sss.pgh.pa.us
Whole thread Raw
In response to Custom sorting  (Jana <jana.vasseru@gmail.com>)
List pgsql-novice
Jana <jana.vasseru@gmail.com> writes:
> I would like to make this ordering on database side since there are two
> appliactions which use the data and both would have to reimplement the
> ordering mechanism. I read several articles on custom sorting, which show
> that i can use any function in the ORDER BY clause, however all the
> examples assume only one input value from which the custom function
> genereates some sort of automatically comparable value. However this
> always involves only a single field - which i cannot use since i need two
> rows to say which one is "higher" and "lower" -

Seems like what you need to do is set up this column as a custom
datatype with its own comparison operators.  If you make a btree
index opclass for the datatype then ORDER BY will understand that
that's how it should sort the values.

            regards, tom lane

pgsql-novice by date:

Previous
From: Jana
Date:
Subject: Custom sorting
Next
From: Dallas Morisette
Date:
Subject: Include result of function call within WHERE clause in results