Hi all I have a xml object where I can get type based on index eg
(string)$this->xmlSimple->test[$i]->type
Type can be 2 values 'B', 'N' and B takes priority over N
Currently I sort my expected array like so:
$sortedArray = [];
$allowedTypes = ["B", "N"];
$count = $this->xmlSimple->test->count();
foreach ($allowedTypes as $type) {
for ($i = 0; $i < $count; $i++) {
if ((string)$this->xmlSimple->test[$i]->type == $type {
$sortedArray [] = $i;
}
}
}
My question is how can achieve the same using sort or usort, so that it is sorted by B first and ordered index by B first and then type N
Thanks