Sort array of objects by specific field

Updates given array with sorted one.

fork add to bundle source
function multi_sort_objects( &$list, $field, $desc = true ) { $handle = function($a, $b) use( $field, $desc) { return !$desc ? $a->$field > $b->$field : $a->$field < $b->$field; }; usort($list, $handle); }

usage

load_function('multi_sort_objects'); $list = [$object_a, $object_b, $object_c]; multi_sort_objects($list, 'name'); // Will return list, sorted by "name" field of each object
← how to use this in app?
create log ...inout