示例#1
0
文件: Radix.cs 项目: yhw9999/Sort
        public void Sort(ref int[] array)
        {
            _positionalNumber = SetNumberLength(array);

            for (int i = 1; i <= _positionalNumber; i++)
            {
                Buckets tmpBuckets = new Buckets();

                for (int j = 0; j < array.Length; j++)
                {
                    string tmpToString = array[j].ToString();

                    if (tmpToString.Length < i)
                    {
                        tmpBuckets.InputBucket(0, array[j]);
                    }
                    else
                    {
                        tmpBuckets.InputBucket(int.Parse(tmpToString[tmpToString.Length - i].ToString()), array[j]);
                    }
                }

                array = tmpBuckets.GetArray();
            }
        }