Skip to content

Instantly share code, notes, and snippets.

@Loupax
Created June 16, 2012 09:28
Show Gist options
  • Select an option

  • Save Loupax/2940690 to your computer and use it in GitHub Desktop.

Select an option

Save Loupax/2940690 to your computer and use it in GitHub Desktop.
Group sorting
function group_sort($array, $order)
{
$new = array();
foreach ($array as $row){
foreach ($order as $ord){
$new[$ord][] = $row[$ord];
}
}
$str = '';
for ($i=0; $i<count($order); $i++)
{
$str .= '$new[$order['.$i.']],';
}
//Remove the last coma
$str = substr_replace($str ,"",-1);
eval('array_multisort('.$str.');');
return $new;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment