I'm running a basic API call which uses the following Google Apps Script:
var response = UrlFetchApp.fetch('https://url.com?startDate=2017-09-01&endDate=2018-04-01', options);
var dataAll = JSON.parse(response.getContentText());
This gives me the following JSON data
{
"kind": "resultTable",
"columnHeaders": [
{
"name": "month",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "averageViewDuration",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "averageViewPercentage",
"columnType": "METRIC",
"dataType": "FLOAT"
},
{
"name": "subscribersGained",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "estimatedMinutesWatched",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "likes",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "subscribersGained",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "shares",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"rows": [
[
"2017-11",
648,
22.06,
13,
47298,
4376,
60,
13,
72
],
[
"2017-12",
641,
21.83,
6,
21284,
1990,
13,
6,
14
],
[
"2018-01",
620,
21.12,
5,
12790,
1236,
14,
5,
12
],
[
"2018-02",
636,
21.65,
2,
11374,
1072,
5,
2,
12
],
[
"2018-04",
604,
20.58,
4,
9760,
968,
14,
4,
9
],
[
"2018-03",
615,
20.94,
8,
8486,
827,
7,
8,
12
]
]
}
While the rows are mostly in date order, there are one or two instances where it isn't. How would I sort the rows to be by date in Google Apps Script so that it starts with 2017-11 first and 2018-04 last?