struct.sort()

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.

struct.sort( sortType=string, sortOrder=string, pathToSubElement=string )

Returns: Array

Argument Description
sortType
string, optional

Define one of the following:

  • numeric: sorts numbers
  • text: sorts text alphabetically, taking case into account (case sensitive)
  • textnocase: sorts text alphabetically, without regard to case (case insensitive)
sortOrder
string, optional

Sort direction:

  • asc (default): ascending (a to z)
  • desc: descending (z to a)
pathToSubElement
string, optional

String or a variable that contains one

Alias: path

Examples

animals = {
        cat:"rat",
        lion:"deer",
        bear:"fish"
};
writedump(animals);
sort = structsort(animals,"text","desc");
writeDump(sort);

See also