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

Argument Reference for the listSort function

list

Required: Yes
A list or variable name

sort_type

Required: Yes
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

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

delimiters

Required: No
Default: ,
Values:
  • ,
  • |
  • ;
  • chr(9)
  • chr(10)
  • chr(13)

Examples sample code invoking the listSort function


Simple example for 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


Example for listSort function with delimiters

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


Simple Example for listSort function using sort_type(textnocase)

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