开发者

Sorting an array

If I have an array of data, what is the best option for sorting them so they are displayed in ascending alphabetical order based on key 2 of the second array within each ArrayObject?

Data

ArrayObject::__set_state(array(
   'job_category_filter_population' => 
  ArrayObject::__set_state(array(
     10225 => 
    ArrayObject::__set_state(array(
       0 => 
      array (
        0 => '10042',
        1 => 'Root',
      ),
       1 => 
      array (
        0 => '10225',
        1 => 'Supply',
      ),
    )),
     10228 开发者_如何转开发=> 
    ArrayObject::__set_state(array(
       0 => 
      array (
        0 => '10042',
        1 => 'Root',
      ),
       1 => 
      array (
        0 => '10228',
        1 => 'X-ray',
      ),
    )),
     10226 => 
    ArrayObject::__set_state(array(
       0 => 
      array (
        0 => '10042',
        1 => 'Root',
      ),
       1 => 
      array (
        0 => '10226',
        1 => 'Team',
      ),
    ))
  ))
))

E.g. Supply, Team and then X-ray?


One would use ArrayObject::uasort and provide a callback function that compares the second element of the second array of its arguments.


Look at using usort() http://php.net/manual/en/function.usort.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜