Customizing Search Results (SharePoint 2010): People Search Results Custom Sorting using XSLT

Overview

By default People Search Results web part sorting capabilities are limited by the following options:

  • Relevance (default)
  • Social Distance
  • Name

Below is presented XSLT based approach how to provide additional sorting options for People Search Results web part.

But before we proceed let me clarify the main limitation of this solution:

  • the specified method allows to sort  search results returned for page only (to control results returned for page ResultsPerPage property is used)
  • applying sorting take place during XSLT transformation (in our case it  is applied to relevant results)

Solution description

Provide custom sorting options values

ParameterBindings property is used for storing custom sort options values and passing them to XSLT:

,where

CustomNameSortLabels and CustomNameSortValues   are used for storing  custom sort option labels and values respectively.

Customize Sort Options  in People Search Results

In order to display custom sort options the following XSLT template is used:

Complete XSLT file for People Search Results  could be found here

Below is shown sorting options control after applying specified XSLT and providing Parameter Binding property value from above example

SortOptions

Sorting for search results is defined using XSLT sorting element:

Complete XSLT file for People Search Results with custom Sort Options could be found here

Results

People Search Result page with results sorted by Last Name is shown below

PeopleSearchResultsCustomSort

References