Once all orders are fetched client side, order them all, newest first

This commit is contained in:
Chris Marslender 2017-11-06 10:01:02 -07:00
parent af7ac97622
commit c9ce1a2bd9
No known key found for this signature in database
GPG Key ID: 5A3FF8E135EABA2C
1 changed files with 18 additions and 0 deletions

View File

@ -43,6 +43,24 @@
var orderindex,
currentOrder;
// Sort orders, newest first
orders.sort(function( a, b ) {
var adate, bdate;
adate = Date.parse( a.date_created_gmt );
bdate = Date.parse( b.date_created_gmt );
if ( adate === bdate ) {
return 0;
}
if ( adate < bdate ) {
return 1;
} else {
return -1;
}
});
for ( orderindex in orders ) {
currentOrder = orders[ orderindex ];