New sort feature with the 4.6.0 PnP Modern Search version!

Since the 4.6.0 version of the PnP Modern Search solution, you can now configure sort fields for SharePoint/Microsoft Search data sources for both default sort and user sort (i.e sort results from the UI). As a result the previous “Edit sort order” option for data sources has been renamed to “Edit sort settings”.

alter-text

That was a long awaited feature already present in v3 but not migrated to v4 due to the new architecture. This is now fixed :D.

What changes compared to previous versions?

The first difference regarding the configuration is about the properties listed in the sort fields dropdown. Now the list is a static list representing all “Sortable” properties in the SharePoint search schema:

alter-text

However, if a property is missing or you need to use a custom property like RefinableString or RefinableDate, you can sill type the property name manually in the dropdown and press ‘Enter’ to validate. Remember the property should be “Sortable” in the search schema to get it work as there is no error validation anymore.

Then you can now decide for a property to be used either for default sorting or user sorting or both. For instance if you want to sort the results initialy by the Created managed property in ascending direction and also allow users to change this direction afterwards, you can set this property as user sort as well with a friendly name for users (i.e. the name that will appeart in the sort dropdown). You can also set other properties to only be sortable in the UI but not as default, like RefinableString01:

alter-text

Once an user sort property is added in the configuration, a sort drop down control appears in the layout (if you don’t set any ‘User sort’ property, the control does not appear):

alter-text

The dropdown control appears on all layouts (except the ‘Details List’)

To sort results on a property, simply click on the property you want to sort in the list (1) and then select the direction (2) ascending or descending.

alter-text

However, here are few things to know about the sort control:

  • By default, when the page opens, the sort order will be the one represented by all properties set as ‘Default sort’ in the configuration (all combined together according to the definition order).

  • You can’t preselect a property in the sort dropdown even if it is configured as a default sort property. It means users don’t kow what is the default sort order.

  • Although you can set multiple properties as user sort in the configuration, you can sort on only one property at a time in the UI.

  • The default sort direction when you click on a property is always ascending (and you can’t change this).

  • You can reset the default sort order by clicking on the “default” option:

Details list layout specificity

We’ve also updated the Details List layout sort options to match this new behavior as it contains its own sort settings. Now in the column option you can make a specific column sortable by choosing among the properties you configured as ‘User sort’ in the data source sort configuration (and only these ones):

alter-text

In the update process, we’ve also removed the static sorting behavior since it was too confusing for users. Now when you sort a specific column, all resuts in the data set are sorted, not only the current page (i.e. a new search request is made):

alter-text

Hope you will find this new feature useful! Don’t hesitate to provide your feedback in the GitHub repository.

comments powered by Disqus