MongoCursor
PHP Manual

MongoCursor::sort

(PECL mongo >=0.9.0)

MongoCursor::sortSorts the results by given fields

설명

public MongoCursor MongoCursor::sort ( array $fields )

인수

fields

The fields by which to sort.

반환값

Returns this cursor.

오류/예외

Throws MongoCursorException if this cursor has started iterating.

예제

Example #1 MongoCursor::sort() example

<?php
// 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));
?>

MongoCursor
PHP Manual