|
Subject: RE: [xsl] Sorting by days of the week From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 23 Dec 2003 09:13:00 -0000 |
>
> I need to sort my output by days of the week. i.e. I have a
> element called 'dayCode' which can contain one of the
> following values: MON1, MON2, TUE1, TUE2, WED1, WED2, THU1,
> THU2, FRI1, FRI2 etc etc
>
> I've tried using <xsl:sort select="dayCode"
> order="ascending"/> but as you would expect, the output order
> is FRI, MON, THU, TUE, WED.
>
> Is there a way to do this kind or sort??
>
Sort on
translate(.,"OUEHRANSMTWF", "1234569")
if you want Sunday last, or
translate(.,"OUEHRANSMTWF", "1234560")
if you want Sunday first. Not tested.
Another approach is to sort (numerically) on
string-length(substring-before("MON TUE WED THU FRI SAT SUN", .))
For a cleaner solution, use an XSLT 2.0 function (or an XSLT 1.0
extension function) to map "MON" to 1, "TUE" to 2, etc.
Michael Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Sorting by days of the week, allan . mccluskey | Thread | [xsl] Re: Sorting by days of the we, Dimitre Novatchev |
| RE: [xsl] Sorting by days of the we, Jarno . Elovirta | Date | [xsl] Re: Sorting by days of the we, Dimitre Novatchev |
| Month |