How do I sort nodes in node_view_multiple()? I created a block with node teasers loaded with node_view_multiple($nodes).

Now I want to order the results:


By Node ID
By the time is was created/updated
Random


Of course I can order them with PHP array functions, but is there a Drupal specific way to do it?
The best way I can think of to do this is using EntityFieldQuery:

$query = new EntityFieldQuery();
  $entities = $query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', 'your_type')
    -&gt;propertyCondition('status', 1)
    -&gt;propertyOrderBy('nid', 'ASC')
    -&gt;propertyOrderBy('changed', 'DESC')
    -&gt;addTag('random') //this gets the query passed through hook_query_alter
    -&gt;execute();


And you will need hook_query_alter to do the random sort because EFQ doesn't do that natively

function icac_custom_query_random_alter(QueryAlterableInterface $query) {
  $query-&gt;orderRandom();
}


To get the nid's for node_load_multiple

$nids = array_keys($entities['node']);