15,120,941 members
See more:
Concatenate Two List & sort concatenated list on the basis of first List.

Suppose First List Data is :
List1 = [21]
[24]
[23]
[26]

Suppose Second List Data is :
List2 = [21]
[32]
[38]
[26]
[25]

List1 and List2 after concatenation i.e
List3 = [21]
[24]
[23]
[26]
[21]
[32]
[38]
[26]
[25]

My query is I want result of the list after sorting in this Fashion : -
List3= [21]
[21]
[24]
[23]
[26]
[26]
[32]
[38]
[25]
Posted

## Solution 4

C#
```ArrayList al = new ArrayList();

for (int i = 0; i < ListBox1.Items.Count; i++)
{
}
for (int i = 0; i < ListBox2.Items.Count; i++)
{
}
al.Sort();
for (int i = 0; i < al.Count; i++)
{
}```

## Solution 2

Hi ,

Try this

C#
```IList<int> List1 = new List<int>() { 5, 7, 1, 4 };
IList<int> List2 = new List<int>() { 3, 11, 9, 2 };
IList<int> Result = List1.Union(List2).OrderBy(p => p).ToList<int>();```
Philip Stuyck 13-Aug-12 2:12am

You are using the union operator, won't it exclude doubles ? The right solution is to use the concat operator.
Prabhakaran Soundarapandian 13-Aug-12 2:20am

Thanks Philip...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Stefan_Lang 170 OriginalGriff 100 Richard Deeming 80 Dave Kreskowiak 50 CPallini 40
 OriginalGriff 540 Richard Deeming 365 Stefan_Lang 170 CHill60 155 Richard MacCutchan 120

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900