Could you do something like splitting the numbers into lists of digits and then take, for example,
radixsort=: ([: ; {:"1 <@$:/. }:"1)`] @.((1>:#) +. 0=#@{.) ? (untested) This eliminates a lot more loops, if it works. Marshall -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of David Ward Lambert Sent: Tuesday, January 18, 2011 11:00 PM To: programming Subject: [Jprogramming] Rosetta code radix sort Another opportunity to show me how to remove explicit loops! http://rosettacode.org/wiki/Radix_sort NB. queue implementation of LSB radix sort. radixSort =: 3 : 0 NB. base radixSort data 16 radixSort y : keys =. x #.^:_1 y NB. compute keys length =. {:#{.keys extra =. (x,-length) {. ,. buckets =. i.x for_pass. 0{i.-length do. keys =. ,&:>/ (buckets,keys{~"1<pass) <@:}./.extra,keys extra =. 1 |. extra end. x#.keys NB. restore the data ) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm