此函数按元素大小的递增顺序对数组进行排序,如果大小相等,则根据字典顺序进行排序。
请有人帮助,在此先感谢:)
function lensort($a,$b){
$la = strlen( $a);
$lb = strlen( $b);
if( $la == $lb) {
return strcmp( $a, $b);
}
return $la - $lb;
}
usort($array,'lensort');
I appreciate the responses, but i want if someone can just write a code to do the same task, not using inbuilt function