double Temp_=[999,233,100,23.5,342,9854,3.5]
用C#从大到小排序。。高人指点。。
for (int i = 0; i < Temp_.Length; i++)
        {
            for (int j = i; j < Temp_.Length; j++)
            {
                if (Temp_[i] < Temp_[j])
                {
                    double temp = Temp_[i];
                    Temp_[i] = Temp_[j];
                    Temp_[j] = temp;
                }
            }
        }

解决方案 »

  1.   

     Array.Sort<double>(Temp_, (d1, d2) => d2.CompareTo(d1));
      

  2.   

    for (int i = 0; i < Temp_.Length; i++)
      {
      for (int j = i; j < Temp_.Length-i-1; j++)
      {
      if (Temp_[j+1] < Temp_[j])
      {
      double temp = Temp_[j];
      Temp_[i] = Temp_[j+1];
      Temp_[j+1] = temp;
      }
      }
      }
      

  3.   

    改一句就可:
     double[] Temp_ = new double[] { 999, 233, 100, 23.5, 342, 9854, 3.5 };
      

  4.   


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                double[] Temp = { 999, 233, 100, 23.5, 342, 9854, 3.5 };
                for (int i = 0; i < Temp.Length; i++)
                {
                    for (int j = i; j < Temp.Length; j++)
                    {
                        if (Temp[i] < Temp[j])
                        {
                            double temp = Temp[i];
                            Temp[i] = Temp[j];
                            Temp[j] = temp;
                        }
                    }
                    Console.Write(Temp[i]+" ");
                }
            }
        }
    }
      

  5.   

    double[] Temp_ = new double[] { 999, 233, 100, 23.5, 342, 9854, 3.5 };
    //降序排
    Array.Sort<double>(Temp_, (d1, d2) => d2.CompareTo(d1));
    有什么不对吗?
      

  6.   

     if (Temp_[j-1] < Temp_[j])
      {
      double temp = Temp_[j-1];
      Temp_[j-1] = Temp_[j];
      Temp_[j] = temp;
      

  7.   


    void Main()
    {
        //linq
    double[] Temp_=new double[]{999,233,100,23.5,342,9854,3.5};
    Console.WriteLine("排序前:****************");
    Temp_.ToList().ForEach(t=>Console.WriteLine(t));
    Console.WriteLine("排序后:****************");
    Temp_=Temp_.OrderByDescending(t=>t).ToArray();
    Temp_.ToList().ForEach(t=>Console.WriteLine(t));
    /*
    排序前:****************
    999
    233
    100
    23.5
    342
    9854
    3.5
    排序后:****************
    9854
    999
    342
    233
    100
    23.5
    3.5*/
    }
      

  8.   


                double[] TempArr = { 999, 233, 100, 23.5, 342, 9854, 3.5 };
                for (int i = 0; i < TempArr.Length; i++)
                {
                    for (int j = i; j < TempArr.Length; j++)
                    {
                        if (TempArr[i] < TempArr[j])
                        {
                            double tempItem = TempArr[i];
                            TempArr[i] = TempArr[j];
                            TempArr[j] = tempItem ;
                        }
                    }
                    Console.Write(TempArr[i]+" ");
                }这是冒泡,数组自带的排序也不错,效率最高,冒泡是基础!最简单,实现容易效率很低.
      

  9.   

    我数组。temp_=["999|aa",,"88|bb",,,"77|ee']
    for(int i=0;i<temp_.length;i++)
    {
          if(temp_[i]!="")//为什么这里不起作用高人指点
                  str=temp[i].split('|')[0];//未将对象引用设置到对象的实例
    }
      

  10.   

    array.sort
    list.Sort(delegate(double a,double b) {...
    from q in arr orderby q select q
      

  11.   

    for(int i=0;i<temp_.length;i++)
    {
      if(temp_[i]!="")//怎么不起作用?
      string str=temp[i].split('|')[0];}//此处必须声明变量str
      

  12.   


    static void Main(string[] args)
            {
                string[] temp={"999|aa","","","88|bb","77|ee"};
                for(int i=0;i<temp.Length;i++)
                {
                    if (temp[i] != "")
                    {
                        string str = temp[i].Split('|')[0];
                        Console.Write(str+"  ");
                    }
                }
            }
      

  13.   

    Array不是可以自己排序的吗··
      

  14.   

    [color=#59ffb]下[/color][color=#59fcb]a[/color][color=#59f9b]c[/color][color=#59f6b]c[/color][color=#59f3b]c[/color][color=#59f0b]c[/color][color=#59edb]c[/color][color=#59eab]c[/color][color=#59e7b]c[/color][color=#59e4b]c[/color][color=#59e1b]c[/color][color=#59deb]c[/color][color=#59dbb]c[/color][color=#59d8b]c[/color][color=#59d5b]c[/color][color=#59d2b]c[/color][color=#59cfb]c[/color][color=#59ccb]c[/color][color=#59c9b]c[/color][color=#59c6b]c[/color][color=#59c3b]c[/color][color=#59c0b]c[/color][color=#59bdb]c[/color][color=#59bab]c[/color][color=#59b7b]c[/color][color=#59b4b]c[/color][color=#59b1b]c[/color][color=#59aeb]c[/color][color=#59abb]c[/color][color=#59a8b]c[/color][color=#59a5b]c[/color]