What would be the best practice to sort a list containing date and a unique identifier for the date, like so:
20110101 5
20110101 78
20150305 103
(That is YYYYMMDD Unique identifier).
I have tried making arrays in php, amongst others:
[0] => Array
(
[date] => 20110101
[order] => 3
)
[1] => Array
(
[date] => 20120101
[order] => 2
)
[2] => Array
(
[title] => 20130101
[order] => 1
)
)
and
$data[] = array('date' => 20100101, 'number' => 122);
$data[] = array('date' => 20110123, 'number' => 120);
$data[] = array('date' => 20111212, 'number' => 123);
$data[] = array('date' => 20091212, 'number' => 121);
$data[] = array('date' => 20151212, 'number' => 100);
$data[] = array('date' => 20151212, 'number' => 99);
but I can’t manage to get the PHP to print, well… anything using different sorting methods (like array_multisort).
What I would want to achieve is a list sorted by date and unique number. The second example would thus begin like:
20151212 100,
20151212 99,
20111212 123
I am mew and fresh to PHP, so please keep the answers at beginner level!
Thanks!!
The best way to attack the problem is by using a callback function to sort the entries by using usort