参考文章:http://www.cnblogs.com/Braveliu/archive/2013/01/21/2870201.html
import java.util.Arrays; public class RadixSortMy { public static void sort(int[] data, int maxLength) //d表示最大的数有多少位 { int currentUnit = 0; //控制键值排序依据在哪一位 int k=0; int[][] temp=new int[10][data.length]; int[]order = new int[10]; //数组order[i]用来表示该位是i的数的个数 while(currentUnit<= maxLength) { for(int i = 0;i<data.length;i++) { int intowoodenNumber = (data[i] / (int)Math.pow(10,currentUnit)) % 10; temp[intowoodenNumber][order[intowoodenNumber]] = data[i]; order[intowoodenNumber]++; } for(int i=0;i<order.length;i++) { if(order[i]!=0) { for(int j=0;j<order[i];j++) { data[k++]=temp[i][j]; } order[i]=0; } } k=0; currentUnit++; } } public static void main(String[] args) { int[] data ={73, 22, 93, 43, 55, 14, 28, 65, 39,123,81}; RadixSortMy.sort(data, 3); System.out.println(Arrays.toString(data)); } }