[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Natural Sort

Subject: Re: Natural Sort
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 24 Jan 2006 12:06:24 +0000
mysite.com
On 1/24/06, Rudi Starcevic <tech@xxxxxxxxxxxx> wrote:
> Hi,
>
>  I'm having trouble sorting my output.
>
> Using PHP as an example there is 'sort' and 'natural_sort' functions.
>
> This is my current output, I'm wanting the output to list from media1
> not from media10.
>
> I've searched the archives but so far I've not found anything, mostly
> been searching under 'natural sort' so this could be a good one to add.
>
> Any advice much appreciated ...
>
> Sample Output:
>
>  media10.mysite.com
>  media11.mysite.com
>  media12.mysite.com
>  media13.mysite.com
>  media14.mysite.com
>  media15.mysite.com
>  media1.mysite.com
>  media2.mysite.com
>  media3.mysite.com
>  media4.mysite.com
>  media5.mysite.com
>  media6.mysite.com
>  media7.mysite.com
>  media8.mysite.com
>  media9.mysite.com
>
> Sample XML:
>
> <servers>
>  <server dn="media1.mysite.com" id="server392" os="FreeBSD 5.1"/>
>  <server dn="media2.mysite.com" id="Server488" os="Fedora Core 1"/>
>     ...
>  <server dn="media10.mysite.com" id="Server433" os="Fedora Core 1"/>
> </servers>
>
> Sample XSL:

Substring out the number and then use that, eg:

<xsl:sort select="substring-after(substring-before(@dn, '.'),
'media')" data-type="number" order="ascending"/>

cheers
andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.