排序

my @numbers;

push @numbers, split while <>;  #将文件读入,使用split分割元素(split默认使用空白字符分割)后加入数组

for (sort {$a<=>$b} @numbers){ #遍历数组中的元素,排序后输出($a和$b是默认的包全局变量)

  printf "%20g\n",$_;

}

原文地址:https://www.cnblogs.com/agostop/p/2343791.html