Sort multidimensional array according to date values in in two elements?
<p>I am trying to sort the arrays (each containing 2 date values) in a multidimensional array. I was able to find a useful function which solves the question for one element, however I was unable to modify it for two.</p>

<p><a href="http://stackoverflow.com/questions/2910611/php-sort-a-multidimensional-array-by-element-containing-date">PHP Sort a multidimensional array by element containing date</a></p>

<pre><code>function date_compare($a, $b)
{
    $t1 = strtotime($a['datetime']);
    $t2 = strtotime($b['datetime']);
    return $t1 - $t2;
}    
usort($array, 'date_compare');
</code></pre>

<p>The problem at hand is sorting comments in which have a post time and an edit time. Essentially I want to sort them from newest to oldest (while keeping both values).</p>

<p>If this is not possible, let me know.</p>

<p>EDIT: Mockup</p>

<pre><code>$array = array(
    [0] =&gt; array(
          [0] =&gt; "Aug:1:2012 12:00:pm", // post date
          [1] =&gt; "Aug:28:2012 12:00:pm"  // edit date
    ),
    [1] =&gt; array(
          [0] =&gt; "Aug:1:2012 12:00:pm",
          [1] =&gt; "Aug:30:2012 12:00:pm"
    )
    [2] =&gt; array(
          [0] =&gt; "Aug:29:2012 12:00:pm",
          [1] =&gt; "Aug:1:2012 12:00:pm"
    )
};
</code></pre>

<p>Should output: $array[1] first (because it has the highest date out of keys 1 &amp; 2) then $array[2], then $array[0].</p>

<pre><code>$array = array(
    [0] =&gt; array(
          [0] =&gt; "Aug:1:2012 12:00:pm",
          [1] =&gt; "Aug:30:2012 12:00:pm" // highest   
    ),
    [1] =&gt; array(
          [0] =&gt; "Aug:29:2012 12:00:pm", // next
          [1] =&gt; "Aug:1:2012 12:00:pm"
    )
    [2] =&gt; array(
          [0] =&gt; "Aug:1:2012 12:00:pm",
          [1] =&gt; "Aug:28:2012 12:00:pm" // lowest
    )
};
</code></pre>
