/* Associative Array to 2D Array PASS: theArray (The associative array to start with), theHeaders (a 1D array of header columns in the order you want them. The headers should match the keys in the assoc array) RETURNS: A 2D array, data only. The header row is not attached. */ function assocArrayTo2D(theArray, theHeaders) { var result = [[ ]]; //move through each row of the array for (let a = 0; a < theArray.length; a++) { for (let c = 0; c < theHeaders[0].length; c++) { result[a].push(theArray[a][theHeaders[0][c]]); } result.push([]); } result.pop(); return result; }