我该如何对数组进行排序

问题描述:

I have this array

Array (  
 [146] => Post Object ( 
 [ID] => 5664  
 [post_author] => 8  
 [post_date] => 2016-04-10 16:21:55  
 [post_content] =>
 )  

 [145] => Post Object (  
 [ID] => 5638  
 [post_author] => 7  
 [post_date] => 2016-03-17 12:23:00  
 [post_content] =>
 )
) 

I want to order my array by the numbers before "=> Post Object".

i.e. I want that the sub-array 145 appear before 146.

Thanks

我有这个数组 p>

  Array(
 [146]  ] =>发布对象(
 [ID] => 5664 
 [post_author] => 8 
 [post_date] => 2016-04-10 16:21:55 
 [post_content] =&gt  ; 
)
 
 [145] =>发布对象(
 [ID] => 5638 
 [post_author] => 7 
 [post_date] => 2016-03-17 12:  23:00 
 [post_content] => 
)
)
  code>  pre> 
 
 

我想在“=&gt之前按数字排序我的数组 ;邮政对象“ em>。 p>

即。 我希望子阵列145出现在146之前。 p>

谢谢 p> div>

You can use ksort function.

ksort($array);

For others behaviour read the related documentation at http://php.net/manual/en/array.sorting.php