Hello,
I have an array that looks like this one:
$data[0]['a'] = "Text";
$data[0]['b'] = "Text";
$data[0]['c'] = 12.23;
$data[1]['a'] = "Text";
$data[1]['b'] = "Text";
$data[1]['c'] = 99.23;
$data[2]['a'] = "Text";
$data[2]['b'] = "Text";
$data[2]['c'] = 0.23;
...
I want to sort this multi dimensional array by [][c].
Therefor I tried the following, but it does not work properly:
usort($data, "scmp");
function scmp($a, $b) {
if ($a['c'] == $b['c']) {
return 0;
}
return ($a['c'] < $b['c']) ? -1 : 1;
}
It would also be great if after sorting the array above would look like this one:
$data[0]['a'] = "Text";
$data[0]['b'] = "Text";
$data[0]['c'] = 0.23;
$data[1]['a'] = "Text";
$data[1]['b'] = "Text";
$data[1]['c'] = 12.23;
$data[2]['a'] = "Text";
$data[2]['b'] = "Text";
$data[2]['c'] = 99.23;
...
Can somebody tell me how to do this task?
thanks,