I have an ArrayList that contains,
[0] = \"1\" [1] = \"10\" [2] = \"2\" [3] = \"15\" [4] = \"17\" [5] = \"5\" [6] = \"6\" [7] = \"27\" [8] = \"8\" [9] = \"9\" >
This is the safest way
aryList is your ArrayList instance
object[] list = aryList.ToArray(); Array.Sort ( list, delegate(object x, object y) { int a = 0, b = 0; if (x == y) return 0; if (x == null || y == null) return x == null ? -1 : 1; int.TryParse(x.ToString(), out a); int.TryParse(y.ToString(), out b); return a.CompareTo(b); } );
result saved into "list" object array