Drupal search api custom sort order I am using search api solr and using views for search results. In my content type, there will be a multilingual field using entity translation and also a field representing language of the node. I am having three languages in the site.

I would like to sort the results by language.

Like, if the site language is set to english,

The search results should first list all english language nodes and then second language and then third. Suggest me a way to fix this.
I fixed this by using hook_search_api_solr_query_alter() and solr function. Here is my code:

function mymodule_search_api_solr_query_alter(array &amp;$call_args, SearchApiQueryInterface $query) {
  if ($_SESSION['language'] == 'en') {
    $call_args['params']['sort'] = 'termfreq(ss_field_name,EN) desc';
  }
}