AngularJS ngRepeat and orderBy.
HTML
<div ng-app="myApp" ng-controller="Ctrl">
<div ng-repeat="card in myCards | orderBy:sortByEitherDate">
<businesscard>{{card.lastName}}</businesscard>
</div>
</div>
JavaScript
angular.module('myApp', [])
.controller('Ctrl', function($scope) {
$scope.myCards = [{
actualStartDate: 'John',
lastName: '3'
}, {
estimatedStartDate: 'Eleanor',
lastName: '2'
}, {
estimatedStartDate: 'Maxwell',
lastName: '4'
}, {
actualStartDate: 'Buzz',
lastName: '1'
}, {
actualStartDate: 'Neil',
lastName: '5'
}];
$scope.sortByEitherDate = function(row) {
if (row.actualStartDate) {
return row.actualStartDate;
}
return row.estimatedStartDate;
}
});