Home  >  Article  >  Backend Development  >  关于php 排序的总结

关于php 排序的总结

WBOY
WBOYOriginal
2016-06-13 12:21:571122browse

关于php 排序的小结
本文记录关于php 自定义排序的实现

<?php //定义数组$arr = array(	256=>array('name'=>'zeopean' , 'grade'=> 89.3),	22 => array('name'=>'daming' , 'grade'=>34.5),	33 => array('name'=>'zpp' , 'grade'=>333),		);//按姓名进行排序function name_sort($x , $y){	return strcasecmp($x['name'], $y['name']);}//按分数排序function grade_sort($x , $y){	return $x['grade'] ';uasort($arr, 'name_sort');var_dump($arr);//按分数  排序echo '**************';echo '<pre class="brush:php;toolbar:false">';usort($arr , 'grade_sort');var_dump($arr);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn