My usort code is not working well
<p>I have problem with sorting this array:</p>

<pre><code>Array
(
    [0] =&gt; stdClass Object
        (
            [id] =&gt; 120
            [registration_date] =&gt; 2012-10-19 16:57:46
            [username] =&gt; Jeff
        )
    [1] =&gt; stdClass Object
        (
            [id] =&gt; 121
            [registration_date] =&gt; 2012-12-23 16:57:46
            [username] =&gt; Peter
        )
    [2] =&gt; stdClass Object
        (
            [id] =&gt; 122
            [registration_date] =&gt; 2012-11-30 16:57:46
            [username] =&gt; Susan
        )

)
</code></pre>

<p>It is stored in variable:</p>

<pre><code>$unsorted_users
</code></pre>

<p>I want to order this array <strong>DESC</strong> by <strong>registration_date</strong> so it looks like this:</p>

<pre><code>Array
    (
        [0] =&gt; stdClass Object
            (
                [id] =&gt; 121
                [registration_date] =&gt; 2012-12-23 16:57:46
                [username] =&gt; Peter

            )
        [1] =&gt; stdClass Object
            (
                [id] =&gt; 122
                [registration_date] =&gt; 2012-11-30 16:57:46
                [username] =&gt; Susan

            )
        [2] =&gt; stdClass Object
            (
                [id] =&gt; 120
                [registration_date] =&gt; 2012-10-19 16:57:46
                [username] =&gt; Jeff
            )

    )
</code></pre>

<p>and it is ordered by registration_date like:</p>

<pre><code>2012-12-23 16:57:46
2012-11-30 16:57:46
2012-10-19 16:57:46
</code></pre>

<p>Instead of original where it was like:</p>

<pre><code>2012-10-19 16:57:46
2012-12-23 16:57:46
2012-11-30 16:57:46
</code></pre>

<p>I am using this code, but it is not working good (the print_r($sorted_users); output of $sorted_users is "1". I don't why it is 1 and not sorted array.)</p>

<pre><code>$sorted_users = usort($unsorted_users, function($a, $b) {
   return $a['registration_date'] - $b['registration_date'];
});
</code></pre>

<p>Any advice why is my code for $sorted_users wrong?</p>
