I have the following code:
private restorePurchases(): Promise<any[]> {
return new Promise<any[]>((resolve) => {
let data: any[] =
[
{
productId: 'com.thewhozoo.prod.message.30days',
date: 1499869861370
},
{
productId: 'com.thewhozoo.prod.message.3days',
date: 1498869861369
},
{
productId: 'com.thewhozoo.prod.message.10days',
date: 1499869851369
},
{
productId: 'com.thewhozoo.prod.message.3days',
date: 1499869861369
}
];
resolve(data);
});
}
As you can see, it returns an array. I would like to sort the array by date
(ascending).
this.restorePurchases().then((purchases: any[]) => {
purchases.sort(by date);
});
Any advise welcome.