0

I have the below data value for print_r($summary->Aging);
I want to rearrange the order of the array object based on AgingType Not Due,< 30,31 to 60 ,61-90 ,91-180 ,181-360,361-720,> 720 in php

Array ( [0] => stdClass Object ( [AgingType] => < 30 [AgingValue] => 114287 ) 
[1] => stdClass Object ( [AgingType] => 31 to 60 [AgingValue] => 76806 ) 
[2] => stdClass Object ( [AgingType] => 61-90 [AgingValue] => 0 ) 
[3] => stdClass Object ( [AgingType] => 91-180 [AgingValue] => 0 ) 
[4] => stdClass Object ( [AgingType] => 181-360 [AgingValue] => 2400 )
[5] => stdClass Object ( [AgingType] => 361-720 [AgingValue] => 0 )
[6] => stdClass Object ( [AgingType] => > 720 [AgingValue] => 0 )
[7] => stdClass Object ( [AgingType] => Not Due [AgingValue] => 0 ) ) 
Array ( [0] => stdClass Object ( [AgingType] => < 30 [AgingValue] => 27159 )
[1] => stdClass Object ( [AgingType] => 31 to 60 [AgingValue] => 0 )
[2] => stdClass Object ( [AgingType] => 61-90 [AgingValue] => 0 ) 
[3] => stdClass Object ( [AgingType] => 91-180 [AgingValue] => 0 ) 
[4] => stdClass Object ( [AgingType] => 181-360 [AgingValue] => 0 )
[5] => stdClass Object ( [AgingType] => 361-720 [AgingValue] => 0 ) 
[6] => stdClass Object ( [AgingType] => > 720 [AgingValue] => 0 )
[7] => stdClass Object ( [AgingType] => Not Due [AgingValue] => 0 ) ) 

I have tried usort($summary->Aging) but not able to sort. I have 3 more set of array like this in print_r($summary->Aging); I want not Due at the begeing

user3386779
  • 6,883
  • 20
  • 66
  • 134
  • Did you intend to give two example arrays? – KIKO Software Dec 18 '20 at 10:34
  • Please [edit] your question to: clarify title of question, include [example] of your code, improve code formatting, provide more information about the problem: results , and anything else that can help us solve your problem. See [ask] – Gander Dec 18 '20 at 10:34
  • Seems like you arrays are already almost sorted. All you really need to do is take "Not Due" from the end and place it at the beginning. – El_Vanja Dec 18 '20 at 10:45
  • ya I need not Due in first – user3386779 Dec 18 '20 at 10:46
  • Then you might take a look at [this](https://stackoverflow.com/questions/4126502/move-value-in-php-array-to-the-beginning-of-the-array). – El_Vanja Dec 18 '20 at 11:07

0 Answers0