I have the following data structure which needs to be sorted. First field to sort by is 'kategorie' and then 'order_by'. It's important that the keys of the objects remain unchanged, the urls get used in other parts of the code.
object(stdClass)#2 (31) {
      ["https://idp1.xxx/idp/shibboleth"]=>
      object(stdClass)#12 (4) {
        ["name"]=>
        string(19) "test"
        ["data"]=>
        string(39) "test"
        ["kategorie"]=>
        string(1) "2"
        ["order_by"]=>
        string(3) "200"
      }
      ["https://idp2.xxx/idp/shibboleth"]=>
      object(stdClass)#1 (4) {
        ["name"]=>
        string(52) "test"
        ["data"]=>
        string(60) "test"
        ["kategorie"]=>
        string(1) "3"
        ["order_by"]=>
        string(3) "110"
      } 
      ["https://idp3.xxx/idp/shibboleth"]=>
      object(stdClass)#1 (4) {
        ["name"]=>
        string(52) "test"
        ["data"]=>
        string(60) "test"
        ["kategorie"]=>
        string(1) "2"
        ["order_by"]=>
        string(3) "120"
      } ...
How it should look like:
object(stdClass)#2 (31) {
      ["https://idp3.xxx/idp/shibboleth"]=>
      object(stdClass)#1 (4) {
        ["name"]=>
        string(52) "test"
        ["data"]=>
        string(60) "test"
        ["kategorie"]=>
        string(1) "2"
        ["order_by"]=>
        string(3) "120"
      } 
      ["https://idp1.xxx/idp/shibboleth"]=>
      object(stdClass)#12 (4) {
        ["name"]=>
        string(19) "test"
        ["data"]=>
        string(39) "test"
        ["kategorie"]=>
        string(1) "2"
        ["order_by"]=>
        string(3) "200"
      }
      ["https://idp2.xxx/idp/shibboleth"]=>
      object(stdClass)#1 (4) {
        ["name"]=>
        string(52) "test"
        ["data"]=>
        string(60) "test"
        ["kategorie"]=>
        string(1) "3"
        ["order_by"]=>
        string(3) "110"
      } ...
Whats the easiest way to achive this? I just can't wrap my head around it...
Edit: usort doesn't work for stdClass Objects This array_multisort doesn't work either
  array_multisort(array_column($entries, 'kategorie'), SORT_ASC,
                  array_column($entries, 'order_by'),      SORT_ASC,
                  $entries);
Edit2: Typcasting to array and the using the above multisort was the answer.
 
    