SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

Like the title says, is there a way to edit the Sort By options for the People Search Results page. Currently the options are 'Default', 'Social Distance', and 'Name'. I'm assuming this is going to require editing, the XSL, but I don't even know what to look for in there. A link to a tutorial would be great.

share|improve this question
up vote 0 down vote accepted

Sort Options control is rendered using XSLT for Search Action Links and Core Results for People web parts. So, the preferable way to customize it using XSLT based approach.


Lets discuss how to provide additional sorting options as shown on picture below

enter image description here

  1. Provide custom sorting options values. ParameterBindings property is used here for storing custom sort options values and passing them to XSLT

           <ParameterBinding Name="CustomNameSortLabels" DefaultValue="Job Title,Department,Last Name" />
           <ParameterBinding Name="CustomNameSortValues" DefaultValue="jobtitle,department,lastname" />
  2. Create XSLT template named CustomSortOptions for retrieving custom sort options from ParameterBindings property and rendering it

        <xsl:template name="GetCustomSortResultUrl">
        <xsl:param name="NameSortValue"/>
        <xsl:value-of select="concat(concat(concat('peopleresults.aspx?k=',$QueryFromUrl),'&amp;v1='),$NameSortValue)"/>
     <xsl:template name="CustomSortOptions">
        <xsl:param name="NameSortValues" select="$CustomNameSortValues"/>
        <xsl:param name="NameSortLabels" select="$CustomNameSortLabels"/>
        <xsl:param name="separator" select="','"/>
          <xsl:when test="not(contains($NameSortValues, $separator))">
            <xsl:if test="string-length($NameSortValues) &gt; 0">
              <xsl:variable name="NameSortUrl">
                <xsl:call-template name="GetCustomSortResultUrl">
                  <xsl:with-param name="NameSortValue" select="$NameSortValues"/>
              <xsl:element name="option">
                <xsl:attribute name="value">
                  <xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($NameSortUrl))"/>
                <xsl:if test="$NameSortValues = $V1FromUrl and string-length($HsFromUrl) = 0">
                  <xsl:attribute name="selected">selected</xsl:attribute>
                <xsl:value-of select="$NameSortLabels"/>
            <xsl:variable name="NameSortUrl">
              <xsl:call-template name="GetCustomSortResultUrl">
                <xsl:with-param name="NameSortValue" select="substring-before($NameSortValues, $separator)"/>
            <xsl:element name="option">
              <xsl:attribute name="value">
                <xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($NameSortUrl))"/>
              <xsl:if test="substring-before($NameSortValues, $separator) = $V1FromUrl">
                <xsl:attribute name="selected">selected</xsl:attribute>
              <xsl:value-of select="substring-before($NameSortLabels, $separator)"/>
            <xsl:call-template name="CustomSortOptions">
              <xsl:with-param name="NameSortValues" select="substring-after($NameSortValues, $separator)"/>
              <xsl:with-param name="NameSortLabels" select="substring-after($NameSortLabels, $separator)"/>
              <xsl:with-param name="separator" select="','"/>
        </xsl:choose>   </xsl:template>
  3. Place call for this template in XSLT after rendering of standard sort options (Relevance, Social Distance and Name)

    <xsl:if test="$ShowPeopleSortDropdown">
                <label for="sortbydd" id="sortbyddlabel">
                  <xsl:value-of select="$SortBy" />
                <select ..>
                  <!-- Standard Sort options goes here  -->
                  <!-- Custom Sort options goes here -->
                  <xsl:call-template name="CustomSortOptions"/>
                <xsl:text disable-output-escaping="yes">&#8195;</xsl:text>

Please follow my post about customizing People Search Results with Custom Sorting options using XSLT for more details

share|improve this answer
Thanks for this. I'll give it a try. How can I go about removing Social Distance as an option? – LoneWolfPR Feb 27 '13 at 17:07

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.