How to order node_load_multiple() function results?
For
There is function node_load_multiple().
$nodes = node_load_multiple(array(), array('type' => 'my_content_type'));
But what will be the order of the nodes in
They will be ordered by NID…
Unfortunately, there is no parameter that managed the order of the results :-(
How we can resolve task if we are going to have results ordered by created time for example?
My answer: node_load_multiple() has the first argument. This is array of nids that have to be loaded.
So we should prepare such array before call node_load_multiple():
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->propertyCondition('type', 'my_content_type')
->propertyCondition('status', 1)
->propertyOrderBy('created', 'ASC')
->execute();
$nodes = node_load_multiple(array_keys($entities['node']));
Is it obvious?