title: how to listObjects in Amazon s3 API order by LastModified?
body: <p>I need to list objects from Amazon s3 in order such that latest uploaded objects should be listed on top ? How it can be done ?</p>
  
  <pre><code>$result = $client-&gt;listObjects(array(
      // Bucket is required
      'Bucket' =&gt; 'string',
      'Delimiter' =&gt; 'string',
      'EncodingType' =&gt; 'string',
      'Marker' =&gt; 'string',
      'MaxKeys' =&gt; integer,
      'Prefix' =&gt; 'string',
  ));
  </code></pre>
  
  <p>There is not option to sort it above ?</p>
  
  <p>Below is my code,</p>
  
  <pre><code>   $items = $this-&gt;get('my.aws_s3.client')-&gt;listObjects(array(
          'Bucket' =&gt; "my_bucket"
      ));
  
  
      foreach ($items as $i) {
          var_dump($i);
      }
  </code></pre>
  
  <p>Below is my output,</p>
  
  <pre><code>string 'my_bucket' (length=19)
  string '' (length=0)
  string '' (length=0)
  string '1000' (length=4)
  boolean true
  array (size=1000)
    0 =&gt; 
      array (size=6)
        'Key' =&gt; string '1286319624.tar.gz' (length=26)
        'LastModified' =&gt; string '2010-10-05T23:00:50.000Z' (length=24)
        'ETag' =&gt; string '"9118de4f6a8e1e21be99d791108eaa57"' (length=34)
        'Size' =&gt; string '90460751' (length=8)
        'Owner' =&gt; 
          array (size=2)
            'ID' =&gt; string '917a9ca91589caf57633aee246d4263777366b4d00aafa9ac3948910f6eb686f' (length=64)
            'DisplayName' =&gt; string 'dbrckll' (length=7)
        'StorageClass' =&gt; string 'STANDARD' (length=8)
    1 =&gt; 
      array (size=6)
        'Key' =&gt; string '1286406023.tar.gz' (length=26)
        'LastModified' =&gt; string '2010-10-06T23:00:50.000Z' (length=24)
        'ETag' =&gt; string '"e0e94040702eb9e18a906140fb706767"' (length=34)
        'Size' =&gt; string '90460758' (length=8)
        'Owner' =&gt; 
          array (size=2)
            'ID' =&gt; string '917a9ca91589caf57633aee246d4263777366b4d00aafa9ac3948910f6eb686f' (length=64)
            'DisplayName' =&gt; string 'dbrckll' (length=7)
        'StorageClass' =&gt; string 'STANDARD' (length=8)
    2 =&gt; 
  </code></pre>
  
  <p>If you see LastModified 
    'LastModified' => string '2010-10-05T23:00:50.000Z' is displayed first and then
     'LastModified' => string '2010-10-06T23:00:50.000Z'</p>
  
  <p>How do I sort it in descending order of LastModified ?</p>