此版本不支持负数和0
public IList<int> RadixSort(int[] nums){//创建 0-9 的基数列表用来统计List<List<int>> mark = new List<List<int>>(10);for (int i = 0; i < 10; i++) mark.Add(new List<int>());//找出最大的位数int count = nums.Max().ToString().Length;while (count > 0){mark.ForEach(list => list.Clear());//计算出要取模的数int a = 1000 / (int)Math.Pow(10,count);for (int i = 0; i < nums.Length; i++){//计算出本位的索引int idx = nums[i] / a % 10;mark[idx].Add(nums[i]);}int start = 0;mark.ForEach(list => {if (list.Count > 0) list.ForEach(val => nums[start++] = val);});--count;}return nums;}
