Re: sort on more than one element

Subject: Re: sort on more than one element
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 1 Nov 2000 10:02:00 -0400 (EST)

>iam using xsl:sort and i need to sort of more than one element
><xsl:sort select="col1;col2"/>
>the parser says that it does not expect a ';'. I tried a ',' - but dint
work too.
>what is the right way to do this.

The right way is to use two xsl:sort elements to specify the two levels of
the sort:

  <xsl:sort select="col1" />
  <xsl:sort select="col2" />

The advantage of this syntax over a comma-separated list is that you can
have different properties attached to the two sorts, such as the order in
which the list is sorted by these cols, or whether the cols are treated as
text or numbers:

  <xsl:sort select="col1" order="ascending" data-type="text" />
  <xsl:sort select="col2" order="descending" data-type="number" />

You can add as many xsl:sorts as you want within an xsl:for-each or an

I hope that this helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread