How can i get most recent or closest date from array of object , i tried to implement sortFunction but no luck, Any idea how can i acheive this task ?
ctrl.js
 $scope.data = [{
        fileDate: Wed Aug 10 2016 10: 10: 44 GMT - 0400(Eastern Daylight Time),
        filename: 'server.log'
    }, {
        fileDate: Tue Aug 30 2016 10: 48: 16 GMT - 0400(Eastern Daylight Time),
        filename: 'server1.log'
    }, {
        fileDate: Wed Aug 31 2016 12: 14: 46 GMT - 0400(Eastern Daylight Time),
        filename: 'server3.log'
    }]
function sortFunction(a, b) {
    var dateA = new Date(a.date).getTime();
    var dateB = new Date(b.date).getTime();
    return dateA > dateB ? 1 : -1;
};
$scope.data.sort(sortFunction);
console.log('DATE ARRAY', $scope.data);
main.html
<tr ng-repeat="file in data | orderBy:sortType:sortReverse">
                <td>{{file.filename}}<label ng-show="showText">currently recording</label></td>
                <td>{{file.fileDate  |date :  "dd.MM.y"}}</td>
                <td><button type="button" class="btn btn-primary" ng-click="downloadServerFile(file.filename)">download</button></td>
            </tr>
 
    