I am looking to do some complex array sorting, but I have no idea where to start. The inner array has three relevant keys for sorting: first the year (numerical ASC), then the month (numerical ASC) and finally the name (alphabetical DESC).
<?php
// the current array:
$array = (
array('year'=>2012, 'month'=>3, 'name'=>'John', 'score'=>12),
array('year'=>2013, 'month'=>8, 'name'=>'Paul', 'score'=>3),
array('year'=>2013, 'month'=>5, 'name'=>'Dennis', 'score'=>7),
array('year'=>2012, 'month'=>3, 'name'=>'Paul', 'score'=>5),
array('year'=>2012, 'month'=>12, 'name'=>'Paul', 'score'=>9),
array('year'=>2012, 'month'=>9, 'name'=>'Mitt', 'score'=>3)
);
// I want to do some sorting with this as output:
$array = (
array('year'=>2012, 'month'=>3, 'name'=>'John', 'score'=>12),
array('year'=>2012, 'month'=>3, 'name'=>'Paul', 'score'=>5),
array('year'=>2012, 'month'=>9, 'name'=>'Mitt', 'score'=>3),
array('year'=>2012, 'month'=>12, 'name'=>'Paul', 'score'=>9),
array('year'=>2013, 'month'=>5, 'name'=>'Dennis', 'score'=>7),
array('year'=>2013, 'month'=>8, 'name'=>'Paul', 'score'=>3)
);
?>
If anyone can point me in the right direction that is really appreciated ;-).
usort()