2D Arrays Library

Installing

Using

Reference documentation

Installing

  1. In the script editor, click on Resources > Manage librairies

This library provides specific methods to work with 2-dimensional arrays. Users can sort and filter an array, count the number of rows matching a criteria and a lot more.

Romain Vialard, May 2012

  1. A popup box opens. Insert the following project key in the textbox: MOHgh9lncF2UxY-NXF58v3eVJ5jnXUK_T and click on the Select button next to it.

  1. Click on the box listing the different versions of the library. Select the Stable version.

  1. Click OK. You can now use this library.

Using

Here's a list of contacts:

I want to remove the duplicates, filter to get only the contacts older than 17 years old and sort by City.

Here is the result:

Reference documentation

unique(Object[][] data, int optColumnIndex)

Returns only the unique rows in the source array, discarding duplicates. The rows are returned according to the order in which they first appear in the source array.

Arguments:

Return Values:

Type

Object[][]

Description

the unique rows in the source array, discarding duplicates.

countif(Object[][] data, String criteria)

Returns the number of rows that meet certain criteria within a JavaScript 2d array.

Arguments:

Return Values:

Type

int

Description

the number of rows that meet the criteria.

indexOf(Object[][] data, int columnIndex, String value)

Returns the first row in which a specified value can be found in a specific column. returns -1 if the value to find never occurs.

Arguments:

Return Values:

Type

int

Description

the first row in which the value can be found.

filterByText(Object[][] data, int columnIndex, String value)

Returns a filtered version of the given source array, where only certain rows have been included.

Arguments:

Return Values:

Type

Object[][]

Description

the filtered rows in the source array.

filterByText(Object[][] data, int columnIndex, String[] values)

Returns a filtered version of the given source array, where only certain rows have been included.

Arguments:

Return Values:

Type

Object[][]

Description

the filtered rows in the source array.

filterByDate(Object[][] data, int columnIndex, Date startDate, Date endDate)

Returns a filtered version of the given source array, where only certain rows have been included.

Arguments:

Return Values:

Type

Object[][]

Description

the filtered rows in the source array.

filterByRange(Object[][] data, int columnIndex, int min, int max)

Returns a filtered version of the given source array, where only certain rows have been included.

Arguments:

Return Values:

Type

Object[][]

Description

the filtered rows in the source array.

sort(Object[][] data, int columnIndex, boolean ascOrDesc)

Returns the rows in the given array, sorted according to the given key column.

Arguments:

Return Values:

Type

Object[][]

Description

the sorted array.

transpose(Object[][] data)

Transposes the rows and columns in the given array.

Arguments:

Nom

data

Type

Object[][]

Description

a JavaScript 2d array

Return Values:

Type

Object[][]

Description

the transposed array.