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;
        }
    }
posted on 2009-06-15 18:23  bestsaler  阅读(100)  评论(0编辑  收藏  举报