You cannot cast IList(T) to IList.
After some sniffing with Reflector, it seems like ArrayList.Adapter(IList).Sort() will first copy the list to an object array, sort the array and then copy the array back to a list:
object[] array = new object[count];
this.CopyTo(index, array, 0, count);
Array.Sort(array, 0, count, comparer);
for (int i = 0; i < count; i++)
{
this._list[i + index] = array[i];
}
You might get boxing overhead if T in your List(T) a value type.
If you need to alter the sequence of the objects in the list that you have, you can do it similarly:
IList<object> unsorted = ...
List<object> sorted = new List<object>(unsorted);
sorted.Sort();
for (int i = 0; i < unsorted.Countt; i++)
{
unsorted[i] = sorted[i];
}
If the list is so huge (as in hundreds of million items) that you cannot make an extra copy in memory, I suggest using a List(T) in the first place or implement your favorite in-place sorting algorithm.