In addition to Dr. Acula's suggestion, you can also use the
Enumerable.Concat() method to chain multiple collections together and then sort them using an OrderBy() call (as the Sort() method doesn't return anything) :
// Your lists
List<int> list1 = new List<int>(new int[] { 2, 5, 1, 4, 6, 9 });
List<int> list2 = new List<int>(new int[] { 5, 4, 7, 8, 2, 1 });
List<int> list3 = new List<int>(new int[] { 8, 8, 7, 4, 1, 5 });
// Sorted list
var sorted = list1.Concat(list2).Concat(list3).OrderBy(x => x);
Participant
786 Points
508 Posts
Best algorithm for sorting low to high from data provided,
Aug 06, 2014 10:11 AM|luckyforu2006|LINK
hi experts,
I have data like
list1<int> contain 2,5,1,4,6,9
list2<int> contain 5,4,7,8,2,1
list3<int> contain 8,8,7,4,1,5
what will the best low to high logic to implements via c# code.
output low to high
1,1,1,2,2,4,4,5,5,5,6,7,7,8,8,8,9
Participant
1322 Points
449 Posts
Re: Best algorithm for sorting low to high from data provided,
Aug 06, 2014 10:27 AM|Dr. Acula|LINK
All-Star
114593 Points
18503 Posts
MVP
Re: Best algorithm for sorting low to high from data provided,
Aug 06, 2014 11:21 AM|Rion Williams|LINK
In addition to Dr. Acula's suggestion, you can also use the Enumerable.Concat() method to chain multiple collections together and then sort them using an OrderBy() call (as the Sort() method doesn't return anything) :
You can see a working example here.