When I enable grouping in the CQWP I can sort in either ascending or descending order based on the values in the field by which I'm grouping. How do I customize that sort order?

For instance, let's say I have a field "PersonType" which has three values: "Players", "Coaches", and "Officials". If I group by field "PersonType" my groups will either be "Coaches", "Officials", and "Players", if I sort ascending, or "Players", "Officials", "Coaches" if I sort descending. How do I customize that sort order?

1 Answer 1


You can use the XSLT <xsl:sort> element to customize your sort order.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">
  <xsl:output method="text"/>

  <xsl:template match="employees">
      <xsl:sort select="salary"/>

  <xsl:template match="employee">
    Last:      <xsl:apply-templates select="last"/>
    First:     <xsl:apply-templates select="first"/>
    Salary:    <xsl:apply-templates select="salary"/>
    Hire Date: <xsl:apply-templates select="@hireDate"/>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.