Skip to content

Instantly share code, notes, and snippets.

@Pleiades
Created November 19, 2012 22:22
Show Gist options
  • Save Pleiades/4114435 to your computer and use it in GitHub Desktop.
Save Pleiades/4114435 to your computer and use it in GitHub Desktop.
Sort an Array by Key
<?php
function ppsc_array_sort (&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment