Sort Op

This is a sort operation.

This operation returns sorts a result by a key or a plain array in ascending or descending order.

Definition using by: ["sort", <by: expression(string, int), string, int>, <direction: expression(string), string>, <from: expression(array)>]

Definition without by: ["sort", <direction: expression(string), string>, <from: expression(array)>]

Usage

Request:

["sort", "asc", ["value", [5, 22, 1, 2, 14, 1]]]

Response:

[1, 1, 2, 5, 14, 22]

Typical Usage

You would use this operation to sort a result from an evaluated response when necessary. Sort can be by a parameter if the result is an array of json objects.

Example Request:

["sort", "age", "desc", ["value", [
  {"name":  "jason", "age": 23},
  {"name":  "anna", "age": 1},
  {"name":  "eli", "age": 22}
]]]

Example Response:

[
  {"name":  "jason", "age": 23},
  {"name":  "eli", "age": 22},  
  {"name":  "anna", "age": 1}
]