Sort and Choose an XML list with XSLT

I am trying to create a style sheet which I can sort elements by name for example or by their account user level

I have got a list displayed with their name, sex and user level but i would like the list sorted. It could be sorting the list by user level ascending 1-4, or it could be by name alphabetically or it could be all the females first then the males.

I have used sort in practice and it works on its own but not combined with other templates.

I would also like to replace the user level with
1 Normal User
2 Festival Volunteer
3 Festival Organiser
4 Administrator

I have got of these woking on their own but this has got me stumped as anything i try hides some of the data


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">
  <h2>My CD Collection</h2>

<xsl:template match="member">
  <xsl:apply-templates select="user/personal/name"/>
  <xsl:apply-templates select="user/personal/sex"/>
  <xsl:apply-templates select="user/account/userlevel"/>

<xsl:template match="name">
  Name: <span style="color:#ff0000">
  <xsl:value-of select="."/></span>
  <br />

<xsl:template match="sex">
  Sex: <span style="color:#00ff00">
  <xsl:value-of select="."/></span>
  <br />

<xsl:template match="userlevel">
	<xsl:when test="1">
		User Level: <span style="color:#0000ff">Normal User</span>

	<xsl:when test="2">
		User Level: <span style="color:#0000ff">Festival Volunteer</span>
	<xsl:when test="3">
		User Level: <span style="color:#0000ff">Festival Organiser</span>
		User Level: <span style="color:#0000ff">Administrator</span>
  User Level: <span style="color:#000ff">
  <xsl:value-of select="."/></span>
  <br />


and an example user

	<user id="1">
			<name>Abbie Hunt</name>
			<address1>108 Access Road</address1>
			<postcode>BA5 8GH</postcode>
			<signupdate>2010-03-26 09:23:50</signupdate>

Fixed it