I am getting data from a form on HTTP request and before writing it on the sheet I want to sort the sheet. I have fetched the google sheet rows and sorted them w.r.t date but the issue is I am unable to overwrite the google sheet with the sorted data.
const doc = new GoogleSpreadsheet('<Google Sheet ID>');
await doc.useServiceAccountAuth({
client_email: '<client email>',
private_key: "<Private Key>",
});
await doc.loadInfo(); // loads document properties and worksheets
const sheet = doc.sheetsById[0]; // or use doc.sheetsByIndex[index]
const rows = await sheet.getRows();
rows.sort(function(o){ return new Date( -o.Timestamp ) });
This is how I am sorting data. I am using Google Sheet Npm Package. Can anyone guide me on how to write rows on a google sheet with newly sorted data