SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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

<xsl:stylesheet xmlns:xsl=""  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"/>

share|improve this answer
Would that be something I add to ItemStyles.xsl? – Chloraphil Nov 6 '13 at 14:06
Yes. Your ItemStyle.xsl and ContentQueryMain.xsl handle the rendering of the data fetched by the CQWP. See here for more details. – Vardhaman Deshpande Nov 6 '13 at 14:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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