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

关于php 排序的小结

WBOY
WBOYOriginal
2016-06-23 13:32:481026browse

本文记录关于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
Previous article:让人不解的私有属性Next article:文件路径问题