What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.
$sortedObjectArary = sort($unsortedObjectArray, $Object-
You could use the usort() function and make your own comparison function.
$sortedObjectArray = usort($unsortedObjectArray, 'sort_by_weight'); function sort_by_weight($a, $b) { if ($a->weight == $b->weight) { return 0; } else if ($a->weight < $b->weight) { return -1; } else { return 1; } }