listSort

Sorts list elements according to a sort type and sort order.
Returns a sorted copy of the list.
[sort_type - quicky]
numeric: sorts numbers
text: sorts text alphabetically, taking case into account
- aabzABZ, if sort_order = "asc"
- ZBAzbaa, if sort_order = "desc"
textnocase: sorts text alphabetically, without regard to case
- aAaBbBzzZ, in an asc sort;
- ZzzBbBaAa, in a desc sort;

listSort(list, sort_type [, sort_order] [, delimiters]) → returns string

listSort Argument Reference

list string
Required

A list or variable name

sort_type string
Required

numeric: sorts numbers
text: sorts text alphabetically, taking case into account
(also known as case sensitive).
- aabzABZ for ascending sort(sort_order = "asc")
- ZBAzbaa for descending sort(sort_order = "desc")

textnocase: sorts text alphabetically, without regard to
case (also known as case-insensitive).
- aAaBbBzzZ for ascending sort(sort_order = "asc")
- ZzzBbBaAa for descending sort(sort_order = "desc")

sort_order string
Default: asc

Values:
  • asc: ascending (a to z) sort order.
  • desc: descending (z to a) sort order

delimiters string
Default: ,

Examples sample code invoking the listSort function

Uses the listSort() function to get the list which sorted by type text(case-sensitive)

list = "COLDFUSION,coldfusion,adobe,LucEE,RAILO";
sortList = listSort(list, "Text", "desc");
writeOutput(sortList);

Expected Result: coldfusion,adobe,RAILO,LucEE,COLDFUSION

Uses the listSort() function with delimiters to get the list which sorted by type numeric

list = "10;20;-99;46;50";
sortList = listSort(list, "Numeric", "asc", ";");
writeOutput(sortList);

Expected Result: -99;10;20;46;50

Uses the listSort() function with delimiters to get the list which sorted by type textnocase(case-insensitive)

list = "10|RED|yeLLow|-246|green|ORange";
sortList = listSort(list, "TextNoCase", "asc", "|");
writeOutput(sortList);

Expected Result: -246|10|green|ORange|RED|yeLLow


Fork me on GitHub