Lucee Function Reference

structtosorted()

Returns a struct sorted by the top level keys in a structure.
Sorts using alphabetic or numeric sorting.

Example

structtosorted(struct base,[any sortTypeOrSortFunc,[string sortOrder,[boolean localeSensitive]]]):struct

Category

struct,sort

Arguments

The arguments for this function are set. You can not use other arguments except the following ones.
Name Type Required Default Value Description
base struct  Yes   A structure with one field (an associative array).  
sortTypeOrSortFunc any  No text The following sort types are available:
  • numeric: sorts numbers
  • text: sorts text alphabetically, taking case into account (case sensitive, defualt)
  • textNoCase: sorts text alphabetically, without regard to case (case insensitive)
    or a function to be used as a comparator
    function(key1, key2)  
  • sortOrder string  No asc Sort direction:
  • asc (default): ascending (a to z) sort order
  • desc: descending (z to a) sort order  
  • localeSensitive boolean  No false Use locale aware sort