对浮点数排序从小到大列出



我想对浮点数List进行从小到大的排序。我试着使用数组。Sort((方法,但它不起作用。下面是我的代码。

List<float> array = new List<float>();
array.Add(x);
listBox1.Items.Add(x);

Just Sort((:

List<float> array = new List<float>();
array.Add(x);
array.Sort();

当对array(相当于List<float>奇怪的名称(进行排序时,我们可以listBox1.Items中间的某个位置插入x。假设listBox1.Items只包含订购的float项目,我们可以放置

// Here's we have WinForms ListBox
int at = listBox1.Items.Count;
for (int i = 0; i < listBox1.Items.Count; ++i) {
if (x < (float) (listBox1.Items[i])) {
at = i;
break;
}
}
listBox1.Items.Insert(at, x);

最新更新