Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts
How Sort Array List of Different DataType in .NET
Like
C#
<pre> System.Collections.ArrayList aa = new System.Collections.ArrayList();
           aa.Add(8.9D);
           aa.Add("Hello");
           aa.Add(1.2);
           aa.Add(2);
           aa.Add(4.5);
           aa.Add("ABC");
           //Before 
           foreach (object obj in aa)
           {
               Console.WriteLine(obj.ToString());
              

           }
           aa.Sort();
           //After
           foreach (object obj in aa)
           {
               Console.WriteLine(obj.ToString());


           }
Posted

1 solution

Strange request, how are you going to compare apples and oranges.

In Any case Array.Sort takes a IComparer so you can give your own comparison function.

See here : Array.Sort(Of T) Method (T(), IComparer(Of T))
 
Share this answer
 

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



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