How can I sort this array of objects by one of its fields, like name or count ?
name
count
Array ( [0] => stdClass Object (
Heres a nicer way using closures
usort($your_data, function($a, $b) { return strcmp($a->name, $b->name); });
Please note this is not in PHP's documentation but if you using 5.3+ closures are supported where callable arguments can be provided.