I am going to assume you have your connection, and collection grabbing sorted already. You will have to use the MongoCollection::group() function to get the result
$keys = array('age' => 1);
$initial = array('count' => 0);
$reduce = "function(doc, out) { out.count++; }";
$result = $collection->group($keys, $initial, $reduce);
var_dump($result)
As for the sort: MongoDB doesn't support sorting the result of a group, you'll have to do in php. This is because group() returns a single document and not a cursor, and it cannot be sorted before it's returned. As per documentation:
"To order the grouped data, simply sort it client-side upon return."