[NOVICE] Custom order - Mailing list pgsql-novice

From Jan Danielsson
Subject [NOVICE] Custom order
Date
Msg-id 1ff2af82-f0f1-5787-9257-9bbf83890108@gmail.com
Whole thread Raw
List pgsql-novice
Hello,

   How would one go about implementing custom rules for sorting?

   I have a table with a column that contains text strings.  These are
complex enough that they can't be sorted using plain ASCII/UTF-8, but
they do have ordinality.  The entries need to be parsed (split up in
fields, but depending on the format there may be different sub-fields,
each relevant to their order).

   Currently I have the sorting logic implemented in python.  I
implemented an object to represent a row and then implemented all the
comparison operators for this object.  Once this was done I could use
the standard sorted() function.

   It would be nice if the database could output the "proper" (read:
custom) order using a simple "ORDER BY <column_name>".

   Is there something analogous to python's declaring objects and their
comparison operators in PostgreSQL?  Something like defining custom
column type which have custom comparison operators?  I would prefer to
implement the comparison logic in C if possible.

--
Kind regards,
Jan Danielsson



pgsql-novice by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [NOVICE] Serializable Isolation Level
Next
From: William Colls
Date:
Subject: [NOVICE] Error Relation xxxx does not exist when trying to insert new row