I have the following array:
Array
(
[3698] => Array
(
[brand] => Brand 1
[rate] => 198
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1805] => Array
(
[brand] => Brand 2
[rate] => 200,6
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1801] => Array
(
[brand] => Brand 3
[rate] => 202,5
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1810] => Array
(
[brand] => Brand 1
[rate] => 172
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
)
And I want it sorted first by Brand and then by Rate, like this:
Array
(
[3698] => Array
(
[brand] => Brand 1
[rate] => 172
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1810] => Array
(
[brand] => Brand 1
[rate] => 198
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1805] => Array
(
[brand] => Brand 2
[rate] => 202,5
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
[1801] => Array
(
[brand] => Brand 1
[rate] => 172
[availability] => 0
[stopsales] => 0
[conditions] => 1
[currencycode] => 1
)
)
I already got it sorted by "brand" but it's doing it alphabetically, which it's not exactly what I need. The way the "brand" should be sorting is the following:
If I'm in Brand 2's website it should appear first, if I'm in Brand 3 then it should appear first and so on.
Currently I'm using this uasort with the following function:
function sortByBrandName($a, $b) {
//global $hotelBrand;
$brandName = strcmp($a['brand'], $b['brand']);
if($brandName === 0)
{
return $brandName;
}
return $brandName;
}
And while it does sort the array by Brand, it doesn't do the trick depending on which site I'm currently on
Thanks in advance for your help!