Gravatar for

Question by saibalini, Apr 1, 2019 4:30 AM

How to implement field sort using html?


We have a drop down list of relevancy and date sort on front end. We bind these items in html. Please find the example below.

  <option class="enabled state-selected CoveoSort slected-value coveo-selected" data-sort-criteria="relevancy"/>
  <option id="sort-by-date" class="enabled state-selected CoveoSort slected-value coveo-selected" data-sort-criteria="datesort"/>

We want the Relevancy and date sort of coveo should fire on selection of dropdown. For relevancy, we use the default coveo relevancy sort. For date sort we are using our custom fields.

We have changed the data-sort-criteria of date sort using script like below.

var computedDateFieldName =
computedDateFieldName = computedDateFieldName + " descending";

We are using coveo 4.0 for sitecore. We have tried many workarounds. Could anyone please suggest how to sort through script on change of dropdown?

1 Reply
Gravatar for

Answer by saibalini, Apr 5, 2019 10:38 AM


I have resolved this using sort criteria:"@computedfield ascending" in query.

Ask a question