Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a generic list of doubles that show on the page like this:

1199.17
1199.17
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1161.67
1199.17
1349.17
1349.17
1349.17
1349.17
1349.17
1349.17
1311.67
1311.67
1311.67
1311.67
1311.67
1349.17
2174.17
2174.17
2174.17
2174.17
2136.67
2136.67
2136.67
2136.67
2174.17
2361.67
2361.67
2361.67
2361.67
2361.67
2361.67
2361.67
2361.67
2399.17
2849.17
2849.17
2849.17
2849.17
2849.17
2849.17
2849.17
2849.17
3111.67
3111.67
3111.67
3149.17

I am trying to order them so that the lowest double is first.

I tried doublePriceList.Sort() but this did not work.

How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
358 views
Welcome To Ask or Share your Answers For Others

1 Answer

using System.Linq;

and

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...