Re: Natural sort

From: F Pighi <francesco.pighi_at_gmail.com>
Date: Fri, 3 Oct 2008 05:34:15 -0700 (PDT)
Message-ID: <af421492-4e2f-43d9-aeac-71a740a468af@34g2000hsh.googlegroups.com>


On Oct 3, 9:51 am, "Álvaro G. Vicario"
<alvaroNOSPAMTHA..._at_demogracia.com> wrote:
> Does Oracle 10g have a so called "natural sort" feature? E.g.:
>
>         foo1
>         foo2
>         foo10
>         foo100
>
> ... rather than:
>
>         foo1
>         foo10
>         foo100
>         foo2

You could do something like this:

select * from YOUR_TABLE
 order by to_number(regexp_substr(YOUR_FIELD,'^[0-9]+')),

          to_number(regexp_substr(YOUR_FIELD,'$[0-9]+')),
          YOUR_FIELD

--
Francesco Pighi
Received on Fri Oct 03 2008 - 07:34:15 CDT

Original text of this message