Skip to content

Instantly share code, notes, and snippets.

@matthews-p
Created November 27, 2024 18:07
Show Gist options
  • Save matthews-p/e184c3eef4aee21a4090b2d6de9b3231 to your computer and use it in GitHub Desktop.
Save matthews-p/e184c3eef4aee21a4090b2d6de9b3231 to your computer and use it in GitHub Desktop.
DistinctListSort
/** DistinctListSort */
/*
FUNCTION NAME: DistinctListSort
DESCRIPTION: Given a n-row by 1-column range of concatenated text,
returns a n-row by 1-column array of the unique values. Return
array is sorted
ARGS:
rng: Range holding original values
delim: Delimiter used to split the concatenated strings
col: Column index you want returned (1st column = 1)
sortorder: 1 for ascending, -1 for descending
EXAMPLE:
=DistinctListSort(A1:A1000,"|",4,1)
*/
DistinctListSort = LAMBDA(
rng,
delim,
col,
sortorder,
SORT(
UNIQUE(
BYROW(
rng,
LAMBDA(
r,
INDEX(
TEXTSPLIT(
r,
delim
),
col
)
)
)
),
,
sortorder
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment