Menu

GeoDB Cities API

Sorting Results

In some cases, API operations returning collection results offer an optional sort parameter. In all such cases, here is the general syntax:

sort=±SORT_FIELD_1,±SORT_FIELD_2,...

Here's what you need to know:

  • The possible values for a given SORT_FIELD are documented in the REST API Docs for that specific operation.
  • By default, sorting will happen in ascending order (A to Z, low to high). To reverse this for a given field, you must prefix the field with a — (minus).
  • You can implement a chained sort (first sort by this, then by that) by including a comma-delimited list of SORT_FIELDs, where the first field will be the primary sort. (And lest you plan on doing anything funny like duplicating the sort field multiple times, the API will quickly smack you back with a validation error, so please save some electricity on needless HTTP 400s.)