# Best algorithm for sorting low to high from data provided,[Answered] RSS

## 2 replies

Last post Aug 06, 2014 11:21 AM by Rion Williams

• luckyforu200...

Participant

786 Points

508 Posts

### Best algorithm for sorting low to high from data provided,

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

• Dr. Acula

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

```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 });

list1.Sort();```

• Rion William...

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) :

```// 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);
```

You can see a working example here.