Skip to content

Instantly share code, notes, and snippets.

@Skaronator
Created September 22, 2019 10:20
Show Gist options
  • Save Skaronator/1a7f27cb640c3d58319fc0b005ac6743 to your computer and use it in GitHub Desktop.
Save Skaronator/1a7f27cb640c3d58319fc0b005ac6743 to your computer and use it in GitHub Desktop.
// Converts [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
// Into [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
const transpose = (array: any[]) => Object.keys(array[0]).map((c: any) => array.map((r: any) => r[c]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment