How to sort ArrayList of DateTime objects in descending order?
Unity3D/Problems 2015. 7. 10. 14:42OrderBy ios Error
First of all, unless you are stuck with using framework 1.1, you should not be using an ArrayList
at all. You should use a strongly typed generic List<DateTime>
instead.
For custom sorting there is an overload of the Sort
method that takes a comparer. By reversing the regular comparison you get a sort in descending order:
list.Sort(delegate(DateTime x, DateTime y){ return y.CompareTo(x); });
Update:
With lambda expressions in C# 3, the delegate is easier to create:
list.Sort((x, y) => y.CompareTo(x));
'Unity3D > Problems' 카테고리의 다른 글
LINQ: How to perform .Max() on a property of all objects in a collection and return the object with maximum value (0) | 2015.07.10 |
---|---|
Unity3D에서 iOS 빌드시 발생하는 에러 trampoline (0) | 2015.07.10 |
StoreKit In App Purchase (0) | 2015.02.06 |
NGUI UIInput한글 문제 (2) | 2014.09.01 |
리스트에서 해당 인덱스부터 마지막까지 제거 하기 (0) | 2014.07.03 |