Skip to content

Instantly share code, notes, and snippets.

@eads
Created March 26, 2012 04:40
Show Gist options
  • Save eads/2202964 to your computer and use it in GitHub Desktop.
Save eads/2202964 to your computer and use it in GitHub Desktop.
Roufa's random sorting
<?php
$results = array();
$terms = array(1, 2);
foreach ($terms as $tid) {
$result = NULL;
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->fieldCondition('field_event_type', 'tid', $tid, '=')
->propertyOrderBy('created', 'DESC')
->pager(10);
$result = $query->execute();
if ($result) {
$results += entity_load('node', array_keys($result['node']));
}
}
shuffle($results);
$sliced = array_slice($results, 0, 10);
dpm($sliced);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment