StructSort()
Returns a sorted array of the top level keys in a structure.
Sorts using alphabetic or numeric sorting, and can sort based on the values of any structure element.
StructSort( base=struct, sortType=string, sortOrder=string, pathToSubElement=string );
Returns: Array
Examples
Non-Member Function
animals = {
cow: {
total: 12
},
pig: {
total: 5
},
cat: {
total: 3
}
};
// Show current animals
Dump(
label: "Current animals",
var: animals
);
// Show animals sorted by total
Dump(
label: "Animals sorted by total",
var: StructSort(animals, "numeric", "asc", "total")
);
See also
- Structures
- Sorting
- struct.sort()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)