#! /Usr/bin/perl-W <br/> use strict; <br/> Use 5.010; <br/> sub getdigit ($) {# Get digit from num <br/> my ($ num, $ flag) =@_; <br/> return $ num/(10 *** $ flag) % 10; <br/>}</P> <p> sub radixsort ($/@) {<br/> my ($ size, $ ARR) = @_; <br/> my @ sortarr; <br/> my $ I; my $ K; <br/> for (0 .. 3) {<br/> my @ COUNT = UNDEF; <br/> for $ I (0 .. $ size) {<br/> my $ digit = getdigit ($ arr-> [$ I], $ _); <br/> $ sortarr [$ digit]-> [$ count [$ di Git] ++] = $ arr-> [$ I]; <br/>}< br/> my $ Index = 0; <br/> for $ I (0 .. 9) {<br/> next if! Defined $ count [$ I]; <br/> for $ K (0 .. $ count [$ I]-1) {<br/> $ arr-> [$ Index] = $ sortarr [$ I]-> [$ K]; <br/> $ index ++; <br/>}< br/>}# for (0 .. 2) <br/>}# for (1 .. 3) <br/>}</P> <p> my @ test_num = QW/49 38 65 937 19 76 13 27 2349 /; <br/> my $ size =$ # test_num; <br/> radixsort ($ size, @ test_num); <br/> say "@ test_num "; </P> <p> this article from the csdn blog, reprinted please indicate the source: http://blog.csdn.net/cliffbaby/archive/2011/05/05/6396137.aspx