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

Re: Collation for dotted decimal?

Subject: Re: Collation for dotted decimal?
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 6 Feb 2006 19:43:10 +0000
xsl sort decimal
On 2/6/06, cknell@xxxxxxxxxx <cknell@xxxxxxxxxx> wrote:
> Given a set of numbers such as the list below, is there a collation for
sorting these in such a way that, for example, 3.3.1.1.11 comes after
3.3.1.1.2?
>
> The numbers are the text nodes of a set of elements produced with an
<xsl:for-each-group>.
>
>
> 3.1.1.3.1
> 3.1.1.3.2.4.2
> 3.1.1.3.4
> 3.2.1.1.7.3.8
> 3.4.4.1.10
> 3.4.4.1.11
> 3.1.1.3.7
> 3.1.1.3.8
> 3.1.1.3.9
> 3.1.1.3.10
> 3.1.1.3.11
> 3.1.1.4.1.1
> 3.1.1.4.1.2
> 3.1.1.4.1.3
> 3.1.1.4.1.4
> 3.1.1.4.1.5
> 3.1.1.4.1.6
> 3.1.1.4.1.7
> 3.1.1.4.1.8
> 3.1.1.3.2.2
> 3.1.1.1.1.1.17

How about the brute force technique:

<xsl:for-each-group ...>
  <xsl:sort select="tokenize(.,'\.')[1]" data-type="number"/>
  <xsl:sort select="tokenize(.,'\.')[2]" data-type="number"/>
  <xsl:sort select="tokenize(.,'\.')[3]" data-type="number"/>
  <xsl:sort select="tokenize(.,'\.')[4]" data-type="number"/>
  <xsl:sort select="tokenize(.,'\.')[5]" data-type="number"/>
  <xsl:sort select="tokenize(.,'\.')[6]" data-type="number"/>
</xsl:for-each>

Obviously this doesn't scale well :)

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.