From: | Herbert Liechti <Herbert(dot)Liechti(at)thinx(dot)ch> |
---|---|
To: | pgsql-general(at)postgresql(dot)org, Jon Lapham <lapham(at)extracta(dot)com(dot)br> |
Subject: | Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ... |
Date: | 2002-02-20 21:07:41 |
Message-ID: | 3C74101D.1050807@thinx.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 20 Feb 2002, Jon Lapham wrote:
...
>
> What I would like to to return the tuples in this order:
> A
> B
> C
> ...
> X
> Y
> Z
> AA
> AB
> ...
>
> Instead of:
> A
> AA
> AB
> ...
> B
> BA
> BB
In Perl you can do it with 3 lines of code. Consider the example
below:
#!/usr/bin/perl -w
use strict;
my @testset = ( 'A'..'Z' );
push @testset, ( 'AA'..'ZZ' );
for ( sort @testset ) {
print "DEFAULT ORDERING: $_\n";
}
for ( sort { length($a) <=> length($b)
||
$a cmp $b } @testset ) {
print "ORDERING USER DEFINED: $_\n";
}
;-)))
Best regards
Herbie
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti http://www.thinx.ch
ThinX networked business services Adlergasse 5, CH-4500 Solothurn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From | Date | Subject | |
---|---|---|---|
Next Message | Cindy | 2002-02-20 21:15:42 | question on function definitions/casts |
Previous Message | Jean-Michel POURE | 2002-02-20 21:01:13 | Re: upgrade to 7.2 & pgdumpall |