3v4l.org

run code in 300+ PHP versions simultaneously
<?php $menu = [ (object)[ 'tid' => 24, 'name' => 'Sample', 'weight' => 3, 'depth' => 0 ], (object)[ 'tid' => 66, 'name' => 'Sample Subcategory', 'weight' => 0, 'depth' => 1 ], (object)[ 'tid' => 67, 'name' => 'Another Example', 'weight' => 1, 'depth' => 0 ], (object)[ 'tid' => 68, 'name' => 'Subcategory for Another Example', 'weight' => 1, 'depth' => 1 ], (object)[ 'tid' => 22, 'name' => 'A third example master category', 'weight' => 0, 'depth' => 0 ] ]; array_multisort(array_column($menu, 'depth'), array_column($menu, 'weight'), $menu); var_export($menu);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
array ( 0 => (object) array( 'tid' => 22, 'name' => 'A third example master category', 'weight' => 0, 'depth' => 0, ), 1 => (object) array( 'tid' => 67, 'name' => 'Another Example', 'weight' => 1, 'depth' => 0, ), 2 => (object) array( 'tid' => 24, 'name' => 'Sample', 'weight' => 3, 'depth' => 0, ), 3 => (object) array( 'tid' => 66, 'name' => 'Sample Subcategory', 'weight' => 0, 'depth' => 1, ), 4 => (object) array( 'tid' => 68, 'name' => 'Subcategory for Another Example', 'weight' => 1, 'depth' => 1, ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.2.0 - 7.2.33
array ( 0 => stdClass::__set_state(array( 'tid' => 22, 'name' => 'A third example master category', 'weight' => 0, 'depth' => 0, )), 1 => stdClass::__set_state(array( 'tid' => 67, 'name' => 'Another Example', 'weight' => 1, 'depth' => 0, )), 2 => stdClass::__set_state(array( 'tid' => 24, 'name' => 'Sample', 'weight' => 3, 'depth' => 0, )), 3 => stdClass::__set_state(array( 'tid' => 66, 'name' => 'Sample Subcategory', 'weight' => 0, 'depth' => 1, )), 4 => stdClass::__set_state(array( 'tid' => 68, 'name' => 'Subcategory for Another Example', 'weight' => 1, 'depth' => 1, )), )

preferences:
195.92 ms | 411 KiB | 5 Q