sorting a generic list of doubles

雨燕双飞 提交于 2019-12-01 06:01:53
using System.Linq;

and

var sortedList = doublePriceList.OrderBy(d => d);

Sort (as per docs) works perfectly, although it isn't returning anything (isn't chainable):

var ds = new List<double>{
    2399.17,
    1199.17,
    // ...
};

ds.Sort();

foreach (double d in ds)
    Console.WriteLine(d);

Try this if you want to print them out

foreach( double d in doublePriceList.OrderBy( d => d ) )
{
  //print d
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!