This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: sorting text-number strings?
- To: xsl-list at mulberrytech dot com
- Subject: Re: sorting text-number strings?
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Fri, 14 Apr 2000 15:48:11 +0100 (BST)
- References: <4.1.20000413201249.02242450@lulu.acns.nwu.edu>
- Reply-To: xsl-list at mulberrytech dot com
> Is there a way to achieve a sort with results?:
> title 1, title2, title 3,..., title 9, title 10, title 11
XSL isn't especially good (actually it's normally hopeless) at infering
structure from character data, so it would have had a much easier time
if the characters and numbers had been separated in the input
<title
name="this string"
number="42"/>
or some such.
Actually I don't understand your description of the input
"title 1, title2, some other name, title 3, ..., title 9, title 10, title 11"
especially as your suggested output is
title 1, title2, title 3,..., title 9, title 10, title 11
what happened to `some other name' and why didn't that have a number,
so I'll ignore that and just give an example that sorts strings
or the form "abc 123" ie characters, space, numbers,
first on the first word, then numerically on the digits.
<xsl:for-each select="whatever">
<xsl:sort data-type="text" select="substring-before(.,' ')"/>
<xsl:sort data-type="number" select="substring-after(.,' ')"/>
...
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list