Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Sorts the elements of a dynamic array.




dynarray An expression that resolves to a dynamic array.


The SORT function takes a dynamic array and returns a dynamic array with its elements sorted in ascending ASCII order. The null string and missing elements are sorted first. Numbers are sorted in ASCII order (for example: 12, 12.3, 123, 13) not numeric order. Numbers are converted to canonical form (removing leading signs and zeros) before sorting; numeric strings are not converted to canonical form.

SORT is provided for compatibility with D3 systems.


The following example uses the SORT function to sort a dynamic array:

cities="New York":@VM:"London":@VM:
"Chicago":@VM:"Boston":@VM:"Los Angeles"
PRINT SORT(cities)
Copy code to clipboard

returns BostonýChicagoýLondonýLos AngelesýNew York

See Also