Re: Natural ordering in postgresql? Does it exist?

From: "Ian Harding" <iharding(at)tpchd(dot)org>
To: <clarkendrizzi(at)hotmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Natural ordering in postgresql? Does it exist?
Date: 2004-12-11 00:56:56
Message-ID: s1b9d582.024@MAIL.TPCHD.ORG
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Numbers as text are ordered like that. Integers are ordered as you would like.

The best hack I have seen if you are stuck with text is

...order by length(numbers_as_test), numbers_as_text

which sorts first by number of "digits" then by text order.

Ian Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
iharding(at)tpchd(dot)org
Phone: (253) 798-3549
Pager: (253) 754-0002

>>> "Clark Endrizzi" <clarkendrizzi(at)hotmail(dot)com> 12/10/04 1:47 PM >>>
Hi all,
I have a field that I'll be ordering and I noticed that ordering is done
logically and would confuse my users here (1,12,16,4,8, etc).

I'm writing an application in PHP that connects to Postgres and while I know
that PHP has some powerful natural ordering functions it would be much
easier if I could just use something from postgres directly. Does there
exist any way to order naturally?

Thanks,
Clark Endrizzi

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Browse pgsql-general by date

  From Date Subject
Next Message Paul Tillotson 2004-12-11 01:21:42 Re: Performance tuning on RedHat Enterprise Linux 3
Previous Message Michael Fuhr 2004-12-11 00:36:43 Re: Significado logo PostgreSQL