How do I Sort a List of Classes by a property?

I have a List of my Class

var Events = List.<Evnt>();

where the Class Evnt has a property enentTime

public class Evnt{
var eventNo :int;
var eventTime  :float;

public function Evnt(evn:int,evt:float){ 
	this.eventNo = evn;this.eventTime = evt;

I want to sort this List by eventTime. If I call Events.Sort() I get an error - ArgumentException: does not implement right interface. How can I sort a List in this manor? Thank You.



You’ll want to use the List.Sort method with a simple delegate. You can write your own custom delegate if you need advanced ordering. Details on MSDN page for Sort.

myList.Sort(delegate(int a, int b) {
    return a.CompareTo(b);