Alphanumeric natural order sorting : need generic solution

From: "Umashanker, Srividhya" <srividhya(dot)umashanker(at)hp(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Alphanumeric natural order sorting : need generic solution
Date: 2013-03-22 07:40:19
Message-ID: 5D5078F9198B04449B9D74EA9E7F3D580CD265B6@G1W3640.americas.hpqcorp.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

All,

I am looking for a generic solution to get the Alphanumeric sorting.

* The user can request for any field to be sorted.

* There is no specific format the alphanumeric string can follow. So that we can split using regex and split and sorted.

* Need an efficient way. Should not degrade performance.

I tried all possible collation example -- select * from test order by name collate "en_US";

Is there someone who has solved this problem with writing a function?

Below are more details -

Database
[cid:image001(dot)png(at)01CE26FE(dot)97F75300]

Table
[cid:image002(dot)png(at)01CE26FE(dot)97F75300]

Rows with orderby
[cid:image003(dot)png(at)01CE26FE(dot)97F75300]

I am expecting

1, bay1
2, bay2
10, bay10
11, bay11

-vidhya

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2013-03-22 10:03:17 Re: Alphanumeric natural order sorting : need generic solution
Previous Message Kalai R 2013-03-22 04:07:12 Problem in "Set search path"