function unique(arr : ArrayList) : ArrayList { var comparer = function compareObject(a, b) { if (a.OrderNumber == b.OrderNumber) { return 0; } else { if (a.OrderNumber < b.OrderNumber) { return 1; } else { return -1; } } } arr.sort(comparer); for (var i = 0; i < arr.length - 1; ++i) { if (comparer(arr[i], arr[i+1]) == 0) { arr.removeAt(i); } } return arr; }