PHP uasort - 按两个键排序[重复]

This question already has an answer here:

I have an array

$DATA = array(
array(
    "id" => "23",
    "rate" => "4.555"
),
array(
    "id" => "12",
    "rate" => "4.555"
),
array(
    "id" => "20",
    "rate" => "4.555"
),

array(
    "id" => "29",
    "rate" => 5.1025"
)   
);

Now i need to sort above array by key: rate (ascending) and id (ascending).

So:

    function mySort($a, $b) {

      return strcmp($a['rate'], $b['rate']); 

    } 

uasort($DATA,'mySort');

Now sort perfect but only by rate....

Adding new funcion:

function mysortID ($a,$b){ //AD
        return ($a['id'] > $b['id']) ? 1 : -1;  
    }

Let's try:

 uasort($DATA,'mySort');
 uasort($DATA,'mySortID');

But doesn't work.... how to that ?

</div>
function mySort($a, $b)
{
    // Check the rates
    $res = strcmp($a['rate'], $b['rate']);

    // If the rates are the same...
    if ($res === 0) {
        // Then compare by id
        $res = $a['id'] > $b['id'] ? 1 : -1;
    }

    return $res;
}