int[] a = new int[] { 2, 1, 3, 6, 8, 7 };
Array.Sort(a,new CompareAge());
foreach (int temp in a)
{
Response.Write(temp.ToString()+"<br>");
}
public class CompareAge:IComparer
{
int IComparer.Compare(object a,object b)
{
int i = 0,j = 0;
int.TryParse(a.ToString(),out i);
int.TryParse(b.ToString(),out j);
return i -j;
}
}
Array.Sort(a,new CompareAge());
foreach (int temp in a)
{
Response.Write(temp.ToString()+"<br>");
}
public class CompareAge:IComparer
{
int IComparer.Compare(object a,object b)
{
int i = 0,j = 0;
int.TryParse(a.ToString(),out i);
int.TryParse(b.ToString(),out j);
return i -j;
}
}