title: how to output a collection of data from mongodb sort by date
body: <p>I want to retrieve 10 rows of latest news from mongodb. 
  First I need to sort the data by the field 'timestamp' by ascending order. Then I need to choose the top 10 rows which are the rows with the latest timestamp. 
  This is how I establish my connection (successfully)</p>
  
  <pre><code>  $m = new MongoClient("mongodb://127.0.0.1");
    $db = $m -&gt;nutch;
    //echo "Database nutch selected";
  
    $collection = $db -&gt; crawl_data; 
  
    $cursor = $collection-&gt;find();
  </code></pre>
  
  <p>This is how I tried to get the data following the PHP manual guide</p>
  
  <pre><code>  $cursor-&gt;sort(array('timestamp' =&gt; 1));
    foreach($cursor as $doc){
    echo $doc["title"];
    }
  </code></pre>
  
  <p>FYI: the data type of timestamp is string: "2015/01/31". I am not sure if this is the reason. </p>
  
  <p>Also,  When I do php with MySql, the browser always tells me at which line the problem is. With mongodb, it does not give you any error reporting except a blank page....</p>