SORT_BY_KEY_CASE_SENSITIVE
Case-sensitive sort a list of objects by a key

Description

Sorts an array of objects by the values of the given key.
This function performs a case-sensitive sort, meaning that all the upper case letters follow all the lower case letters. This is for advanced use only, because typically you would like to perfrom a case insensitive sort, so unless you have a reason to sort case-sensitively then you should use SORT\_BY\_KEY instead!
If the objects do not contain text or number values under the given key, the sort might not behave as expected.
The third parameter can be used to sort in ascending (default) or descending order.

Function signature

1
SORT_BY_KEY_CASE_SENSITIVE(list: Array, key: String, order: String = asc) => Array
Copied!
Parameter
Description
List
List to sort
Key
Key whose value to sort by
Order
Order to sort in ("asc" for ascending, "desc" for descending); defaults to ascending.

Examples

1
array = [
2
{
3
"name": "Ken",
4
"year": 2010
5
},
6
{
7
"name": "jane",
8
"year": 1987
9
},
10
{
11
"name": "karen",
12
"year": 1980
13
},
14
{
15
"name": "John",
16
"year": 2005
17
}
18
]
Copied!
Formula
Return value
SORT_BY_KEY_CASE_SENSITIVE(array, "name")
[{"name":"John","year":2005},{"name":"Ken","year":2010},{"name":"jane","year":1987},{"name":"karen","year":1980}]
SORT_BY_KEY_CASE_SENSITIVE(array, "name", "desc")
[{"name":"karen","year":1980},{"name":"jane","year":1987},{"name":"Ken","year":2010},{"name":"John","year":2005}]
SORT_BY_KEY_CASE_SENSITIVE(array, "year", "asc")
[{"name":"karen","year":1980},{"name":"jane","year":1987},{"name":"John","year":2005},{"name":"Ken","year":2010}]
Last modified 1yr ago
Export as PDF
Copy link