Transpose List of Lists | ARRAY_TRANSPOSE

Syntax

ARRAY_TRANSPOSE( [value] )

Parameters

value
The ARRAY of ARRAY entries to be transposed.

Return Value

A new ARRAY with the items transposed.

Description

Create a transposed copy of an ARRAY of ARRAYS. A transposition, in this context, is one which the rows and columns of a 2-dimensional ARRAY are switched. For example, if the array were represented as the following table:
AB
12
It's transposition would result in this table:
A1
B2
If the value is not an ARRAY, it is coerced into one using the ARRAY operation. If the entries within the value are not ARRAYS, they are also coerced into one using the ARRAY operation.

Examples

ARRAY_TRANSPOSE([]) # returns []
ARRAY_TRANSPOSE([["a", 1], ["b", 2], ["c", 3]]) # returns [["a", "b", "c"], [1, 2, 3]]
ARRAY_TRANSPOSE([[1, 2, 3], [], [4, 5], [6]]) # returns [[1, 4, 6], [2, 5], [3]]
ARRAY_TRANSPOSE("not a list") # returns ["not a list"]
Combine a list of ids with a list of names
# ${ids} is [
#  "adams-id",
#  "bettys-id",
#  "charlies-id",
#  "dianas-id"
# ]
# ${names} is [
#    "Adam",
#    "Betty",
#    "Charlie",
#    "Diana"
# ]
ARRAY_TRANSPOSE([${ids}, ${names}])
# returns [
#   ["adams-id", "Adam"],
#   ["bettys-id", "Betty"],
#   ["charlies-id","Charlie"],
#   ["dianas-id", "Diana"]
# ]