Werbung
MongoCursor::sort
(PECL mongo >=0.9.0)
MongoCursor::sort — Sorts the results by given fields
Beschreibung
Parameter-Liste
- fields
-
The fields by which to sort.
Rückgabewerte
Returns this cursor.
Fehler/Exceptions
Throws MongoCursorException if this cursor has started iterating.
Beispiele
PHP Code
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
// sort x ascending
$cursor->sort(array('x' => 1));
// the associative array is ordered, for instance, these two
// examples might yield different results:
// sort date ascending and age descending
$cursor->sort(array('date' => 1, 'age' => -1));
// sort age descending and date ascending
$cursor->sort(array('age' => -1, 'date' => 1));