2012年9月8日

perl sort 函数用法

摘要: sort函数用来对数组进行排序。用法如下:#按字符排序 @articles = sort @files;#按字符排序,显式说明 @articles = sort {$a cmp $b} @files;#按字符排序,忽略大小写 @articles = sort {uc($a) cmp uc($b)} @files;#按字符排序,逆序 @articles = sort {$b cmp $a} @files;#按数字顺序排序 @articles = sort {$a <=> $b} @files;#按数字顺序排序,逆序 @articles = sort {$b <=> $a} 阅读全文

posted @ 2012-09-08 19:57 云中道长 阅读(592) 评论(0) 推荐(0) 编辑

导航