From: hubert depesz lubaczewski <depesz@depesz.com>
To: Mike Hepworth <michael.w.hepworth@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6056: sorting issues
Date: Tue, 14 Jun 2011 13:14:15 +0200
Message-ID: <20110614111415.GA16856@depesz.com> (raw)
In-Reply-To: <201106132152.p5DLq6Hq046860@wwwmaster.postgresql.org>
References: <201106132152.p5DLq6Hq046860@wwwmaster.postgresql.org>
On Mon, Jun 13, 2011 at 09:52:06PM +0000, Mike Hepworth wrote:
> I execute the following sql statment:
>
> select * from (values('HALL, ANDY'),('HALLBERG, FRANK'),('HALLDEN,
> DOUGLAS'),('HALL, DOUGLAS') ) x ORDER BY 1;
>
> and get the following results
>
> HALL, ANDY
> HALLBERG, FRANK
> HALLDEN, DOUGLAS
> HALL, DOUGLAS
> Please Help...
it would help if you would say what do you think is wrong with it.
because, the data is well sorted - prefix hall, and then, the next
sortable character is:
A
B
D
D
in 3rd and 4th string 2nd character is also taken into consideration
because 1st is the same, so it becomes:
A
B
DE
DO
so the sort order is correct.
if you'd expect to get output:
> HALL, ANDY
> HALL, DOUGLAS
> HALLBERG, FRANK
> HALLDEN, DOUGLAS
then the proper solution is to use separate fields for lastname and
firstname, and not put them both in the same column.
In Pg 9.1 you will be able to sort it the way you want using COLLATE
support.
with current situation, you can try to split every string using ", ",
and sort splitted elements separately.
Best regards,
depesz
--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: depesz@depesz.com, michael.w.hepworth@gmail.com
Subject: Re: BUG #6056: sorting issues
In-Reply-To: <20110614111415.GA16856@depesz.com>
References: <201106132152.p5DLq6Hq046860@wwwmaster.postgresql.org> <20110614111415.GA16856@depesz.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox