EntityFieldQuery supports sorting on both properties and fields:

https://api.drupal.org/api/drupal/includes!entity.inc/function/EntityFie...

Should be trivial to implement this as another #era_query_settings setting ('field_orderby' and 'property_orderby')

I am not 100% sure of use cases, but I would for instance want to maybe show more recent entities first on the list, or more popular entities first, etc...

Right now it is not clear in what order the entities are returned. Ideally we could sort by relevance/text match quality as well.

I am on a project that may develop this in the next several months, just putting this out there in case anyone has a solution or would like to contribute.

Comments

Fool2 created an issue.

sakadava’s picture

It doesn't look like this has been added to the module so in the meantime, sorting could be achieved using hook_entity_query_alter, using something like this:

function mymodule_entity_query_alter($query) {
  if (isset($query->tags['era_query'])) {              // Some check to target our specific entity reference autocomplete query
    $query->propertyOrderBy('name',  'ASC');    // In this case sort by entity name
  }
}