Although MondoDB does not offer it, but you can very easily do it in PHP or any other language. Here is how to do it in PHP.
<?php
$cn = new MongoClient($dbHost);
$db = $cn->selectDB($dbName);
$col = new MongoCollection($db, $collectionName);
$cursor = $col->find();
$cursor = iterator_to_array($cursor);
foreach ($cursor as $key => $row) {
$name[$key] = $row['name'];
$email[$key] = $row['email'];
}
//$name is the field to sort on, taken from the above loop
//You can use SORT_ASC or SORT_DESC
array_multisort($name, SORT_ASC, $cursor);
foreach ($cursor as $doc) {
echo $doc['name'].’-’.$doc['email'].’<br/>’;
}
?>