usort($myArray, function($a, $b) { return strcmp($a->myPropery, $b->myPropery); });
Sort by predefined order:
$predefinedOrder = array(1,5,2,6); usort($arrayOfObjects, function ($a, $b) use ($predefinedOrder ) { $flipped = array_flip($predefinedOrder); $left = $flipped[$a->myPropery)]; $right = $flipped[$b->myPropery)]; return $left >= $right; });