Here's my code:
function getDetailsForShipmentId() {
   //Fill code here
   var strTable="<table id='myTable' border='2'><tr><th>Shipment Number</th><th>Port</th><th>Date</th><th>Time</th><th>Status</th></tr>";
   var array=[];
   array=populateShipmentDetails();
   array.sort(sortFunction);
   var i, found, obj;
   var id=document.getElementById("shipmentId").value;
    for (i = 0; i < array.length; i++) {
        obj = array[i];
        if (obj.shipmentId == id) {
            strTable+="<tr><td>"+obj.shipmentId+"</td><td>"+obj.port+"</td><td>"+obj.date+"</td><td>"+obj.time+"</td><td>"+obj.status+"</td></tr>";
        }
    }
    strTable+="</table>";
    document.getElementById("result").innerHTML=strTable;
}
function sortFunction(a,b){  
    var dateA = new Date(a.date).getTime();
    var dateB = new Date(b.date).getTime();
    return dateA > dateB ? 1 : -1;  
};
I am able to get the result searching through the javascript array but the sorting is not happening. Could somebody help?
Here's my output:

 
     
     
    