string str = "8366,45,123,789";
            int[] array = Array.ConvertAll<string, int>(str.Split(new char[]{','}), new Converter<string, int>(Convert.ToInt32));

解决方案 »

  1.   

    漏了一句
     Array.Sort(array);
      

  2.   

    先把数据保存到数组中,然后使用array.sort 进行排序,用法看MSDN
      

  3.   

        public static void BubbleSort(int[] list)
        {
            for (int i = 0; i < list.Length; i++)
            {
                for (int j = i; j < list.Length; j++)
                {
                    if (list[i] < list[j])
                    {
                        int temp = list[i];
                        list[i] = list[j];
                        list[j] = temp;
                    }
                }
            }
        }    protected void Page_Load(object sender, EventArgs e)
        {
            int[] list = { 8366, 45, 123, 789 };
            BubbleSort(list);
            for (int i = 0; i < list.Length; i++)
            {
                Response.Write(list[i].ToString()+"</br>");            
            }
        }
      

  4.   

                ArrayList list = new ArrayList ();
                int size = 0; 
                do
                {
                    int a = Convert.ToInt32(Console.ReadLine());
                    list.Add(a);
                    size++;
                }
                while (size < 5);
                list.Sort();
                for (int i = 0; i < list.Count; i++)
                {
                    Console.WriteLine("{0} : {1}", i, list[i]);
                }
                Console.ReadLine();
      

  5.   

    array.sort用这个可以,但是建议采用这种方法...冒泡排序....