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

关于php 排序的小结

WBOY
Release: 2016-06-23 13:32:48
Original
1060 people have browsed it

本文记录关于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);
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template