ListSort

Sorts list elements according to a sort type and sort order.

ListSort( list, sort_type [, sort_order [, delimiters [, includeEmptyFields ] ] ] )

Returns: String

Argument Description Default
list
string, required

a string list

sort_type
string, required

there are different sort types:

  • numeric (sort by number)
  • text (sorts text alphabetically and case sensitive)
  • textnocase (sorts text alphabetically and ignore case sensitivity)
sort_order
string, optional

sort direction:

  • asc(default): ascending sort order
  • desc: descending sort order

asc

delimiters
string, optional

Characters that separate list elements. The default value is comma.

Alias: delimiter

,

includeEmptyFields
boolean, optional

if set to true, empty values are included as well

Examples

Simple example for listSort() with type numeric,text(case-sensitive) & textnocase(case-insensitive)

listNumeric="4,-16,2,15,-5,7,11";
writeOutput(listsort(listNumeric,"numeric","asc"));
writeOutput("<br><br>");
writeOutput(listsort("Adobe/coldfusion/Lucee/15/LAS","text","desc","/"));
writeOutput("<br><br>");
writeOutput(listsort("Adobe,coldfusion,lucee,15,LAS","textnocase","asc"));
writeOutput("<br><br>");
//Member function
strList="Lucee,ColdFusion,LAS,SUSI,AdoBe";
writeDump(strlist.listSort("textnocase","asc"));

See also