Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created June 16, 2012 13:52
Show Gist options
  • Save hanafiah/2941379 to your computer and use it in GitHub Desktop.
Save hanafiah/2941379 to your computer and use it in GitHub Desktop.
array_multisort
<?php
$listSort[] = array('email' => 'a@b.c', 'name' => 'x', 'umur' => 21);
$listSort[] = array('email' => 'a2@b.c', 'name' => 'y', 'umur' => 11);
$listSort[] = array('email' => 'a3@b.c', 'name' => 'z', 'umur' => 33);
foreach ($listSort as $key => $row) {
$name2[$key] = $row['name'];
$umur2[$key] = $row['umur'];
}
array_multisort($umur2, SORT_DESC, $name2, SORT_ASC, $listSort);
echo '<pre>';
echo print_r($listSort);
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment