# Sort Container Array

The statement is used to sort the array item in a container. The optional key field can contain any of the escape sequences defined in Escape Sequences.

Each item in the array establishes a sort test value as follows:

- If the array item is an object; and it has an item with the specified key; and the item is a string; the string value is the sort parameter.
- If the array item is a string or number (boolean included), the item's value is the sort test value.
- If neither of the preceding is true, the sort test value is an empty string and the sort is indeterminate.

Assuming the following container array in obj:

      "genres" : [
        {
          "name" : "rock"
        },
        "blues",
        {
          "name" : "classical"
        }
      ]

executing:

    Sort container array 'obj.genres' key 'name'

will result in:

      "genres" : [
        "blues",
        {
          "name" : "classical"
        },
        {
          "name" : "rock"
        }
      ]

Containers

Directed Paths