My array has sorting values from 1-6.
Array: 2 5 6 2 5 1 1
and then I can get the two's first before anything else for example.
So it would be like 2 2 5 6 5 1 1
. But, then I need to sort by the other sorting values and dates.
Example: 2 2 1 1 5 5 6
and those also have dates attached to them and needs to be sorted in descending order.
Final example:
2 - 2012-06-02
2 - 2012-06-01
1 - 2012-03-05
1 - 2012-03-01
5 - 2012-08-09
5 - 2012-01-01
6 - 2012-11-29
My function looks like this at the moment and is used by the usort function. ObjektTyp is the sorting value, different numbers depending on what type of house it is. All these values comes from a XML-source.
function sort_by_type(&$array, $sort = NULL)
{
usort($array, function($a, $b) use ($sort)
{
if ($a["ObjektTyp"] == $sort) {
return -1;
} else {
return 1;
}
});
}
I would love to get some help with this, been pulling my hair all day.
Thank you very much!