arraySort

Overview ColdFusion Open BlueDragon Lucee

Sorting function where comparing algorithm is customized and passed as closure. The two objects that need to be compared are passed as two arguments to the closure function. The closure function should return 1,0 or -1 to signify that first object is larger, equals and shorter than second obj.

Attributes

Name Required Type Default Description
array Yes Array Array to iterate over
10
function Yes Closure Closure function to compare elements
10
localeSensitive No Boolean Performs locale sensitive sorting, if true. Default is false
4
locale_sensitive No if true it does a locale sensitive sorting.
4
sorttype_or_closure No value can be a string or a closure/function. a string must be one of the following values: - "numeric": sorts numbers - "text": sorts text alphabetically, taking case into account (case sensitive) - "textnocase": sorts text alphabetically, without regard to case (case insensitive) if you define a closure/function, the closure/function must accept 2 parameters of any type and return: -1, if first parameter is "smaller" than second parameter 0, if first parameter is equal to second parameter 1, first parameter is "bigger" than second parameter
sort_order No String asc: ascending sort order. Default. - aabzABZ or aAaBbBzzZ, depending on value of sort_type, for letters - from smaller to larger, for numbers desc: descending sort order. - ZBAzbaa or ZzzBbBaAa, depending on value of sort_type, for letters - from larger to smaller, for numbers
sort_type Yes String numeric: sorts numbers text: sorts text alphabetically, taking case into account (also known as case sensitive). All letters of one case precede the first letter of the other case: - aabzABZ, if sort_order = "asc" (ascending sort) - ZBAzbaa, if sort_order = "desc" (descending sort) textnocase: sorts text alphabetically, without regard to case (also known as case-insensitive). A letter in varying cases precedes the next letter: - aAaBbBzzZ, in an ascending sort; preserves original intra-letter order - ZzzBbBaAa, in a descending sort; reverses original intra-letter order