For the first question: if you return an interface, you retain more flexibility. You can change the implementation later to return a different concrete type. On the other hand, it obviously gives the caller less information, so they may not be able to perform certain operations. (e.g. if you return List<T>
, the caller can use ConvertAll etc... which they can't if you only declare that you return IList<T>
.) In some situations it's worth specifying the concrete type; I generally prefer to at least start with interfaces, and only move to put the concrete type as the return type if I find that I frequently want to use the extra methods available.
Secondly, no standard collection interfaces have a Sort
method. On the other hand, you could write an extension method to sort any IList<T>
. Personally I usually prefer the LINQ OrderBy
, OrderByDescending
, ThenBy
and ThenByDescending
methods... although they return a new sequence, rather than sorting in place.