Added a new function to sort an associative array by key

This commit is contained in:
Alejandro Gallardo Escobar 2015-05-04 20:10:13 +02:00
parent c95f70dde7
commit 7ae97fa48b
1 changed files with 8 additions and 0 deletions

View File

@ -2362,4 +2362,12 @@ function set_unless_defined (&$var, $default) {
return false;
}
}
function sort_by_column (&$array_ref, $column) {
if (!empty($column)) {
usort($array_ref, function ($a, $b) {
return strcmp($a[$column], $b[$column]);
});
}
}
?>