downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoCursor::tailable> <MongoCursor::slaveOkay
[edit] Last updated: Fri, 18 Sep 2009

view this page in

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


add a note add a note User Contributed Notes MongoCursor::sort
klgleb at gmail dot com 05-Jul-2011 11:00
Here both arrays are equal

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

 
show source | credits | stats | sitemap | contact | advertising | mirror sites