不管在现实生活中还是程序世界里,顺序总是很重要——真不敢想象一个没有顺序的世界会什么样子!PHP数组也不例外。PHP提供了四组针对PHP数组进行排序的函数,前三种都是针对一维数组的,我们先说这三种,第四种对多维数组的排序在下一篇文章中说,那个有点复杂。
第一组 :sort 和 rsort ,按照PHP数组键值的顺序asc和逆序desc进行排序,同时破坏原来数组的索引关系——其实是删除索引之后重新建立从0开始的数字索引。看一下例程:
<span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,0); FONT-WEIGHT: bold; PADDING-TOP: 0px"><?php </span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">=</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">array</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,255); PADDING-TOP: 0px">"a"</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">=></span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">1</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">2</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">sort</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">var_dump</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">rsort</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">var_dump</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,0); FONT-WEIGHT: bold; PADDING-TOP: 0px">?></span></span> 로그인 후 복사 |
看一下第一个输出结果,第一个输出:
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
第二个输出:
array(2) {
[0]=>
int(5)
[1]=>
int(4)
}
发现没有我们原来定义的索引a哪里去了?哪里去了?可以肯定的说是被他们无情的删除了,你要是对原来的索引关系并不在意的话,可以使用他们!
第二组函数:asort 和 arsort ,这两个函数就比较厉害一点了,只要他们可以保留数组原有的索引关系,把上例的sort 和 rsort 分别用这两个函数替换一下,看运行结果:
array(2) {
["a"]=>
int(1)
[0]=>
int(2)
}
array(2) {
[0]=>
int(2)
["a"]=>
int(1)
}
这个一看就明白的,不用说了吧!
第三组PHP数组排序函数:krsort 和 ksort 这两个不同于以上两组,这两函数是对键名进行排序的,大家可以把上例的函数替换成这两个,看看具体运行结果,这里也不说了,不然这个文章写的就太长了,怕有些兄弟没有耐心看到本文的重点,虽然重点就在下边!
通过自定义函数对PHP数组进行排序,有三个函数分别是:
uasort 通过自定义函数对PHP数组的键值进行排序,并且保留原来的索引关系。
uksort 通过自定义函数对PHP数组的键名进行排序,并且保留原来的索引关系。
usort通过自定义函数对PHP数组的键值进行排序,并且删除原来的索引关系,从零开始建立新的索引。
这个地方当然需要一个例子:
<span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px"><!--</span>p <span style="PADDING-BOTTOM: 0px; FONT-STYLE: italic; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(102,102,102); PADDING-TOP: 0px">//首先顶一个函数,这个函数需要接受两个参数,并且返回值是一定的</span> <span style="PADDING-BOTTOM: 0px; FONT-STYLE: italic; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(102,102,102); PADDING-TOP: 0px">//第一个参数等于第二个参数的时候返回0,小于的时候返回-1,大于返回1</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,0); FONT-WEIGHT: bold; PADDING-TOP: 0px">function</span> cmp<span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$b</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">{</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">+=</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">1</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$b</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">+=</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">3</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span><span style="PADDING-BOTTOM: 0px; FONT-STYLE: italic; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(102,102,102); PADDING-TOP: 0px">//改变这些值之后进行比较</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(177,177,0); PADDING-TOP: 0px">if</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">==</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$b</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(177,177,0); PADDING-TOP: 0px">return</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">0</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(177,177,0); PADDING-TOP: 0px">return</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">&</span>lt<span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$b</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span>?<span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">-</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">1</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">:</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">1</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">}</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">=</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">array</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">1</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">4</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">3</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(204,102,204); PADDING-TOP: 0px">5</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">uasort</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">,</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,255); PADDING-TOP: 0px">'cmp'</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(153,0,0); PADDING-TOP: 0px">var_dump</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">(</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,0,136); PADDING-TOP: 0px">$a</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(0,153,0); PADDING-TOP: 0px">)</span><span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">;</span> <span style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(51,153,51); PADDING-TOP: 0px">--></span> 로그인 후 복사 |
输出结果:
array(4) {
[0]=>
int(1)
[3]=>
int(5)
[1]=>
int(4)
[2]=>
int(3)
}
,呵呵……是不是比不排序还乱呢?我们这里只是演示了使用的方法而已,具体你用到的时候自己搞吧!你要是不对这些数值进行操作之后再比较,例如我们这里:
$a+=1;
$b+=3;//改变这些值之后进行比较
那么你还不如直接用sort呢是不是?
其他两个跟这个差不多就不说了,随后战地会对PHP针对多维数组进行排序做一些实验,然后把结果和过程告诉大家,稍等啊!