Help:Inline queries/Sorting results

Subpages of the main Help page: **3.3 /Sorting results **3.4 /Configuring labels or table headers
 * 1 /Introduction to "hash"ask
 * 2 /The "hash"show parser function
 * 3 /Standard parameters for inline queries
 * 3.1 /Result limits and links to further results
 * 3.2 /Introduction and default text
 * 3.5 /Changing the first result column
 * 4 /Result formats
 * 5 /Exporting query results: RSS, etc.
 * 6 /Using templates for custom formatting

It has been explained in Help:Selecting pages that query results can be ordered by one or more properties. As explained there, Special:Ask has additional input fields to specify sort properties and ordering. In inline queries, sort properties are defined with the parameter sort, and the order can be set with the parameter order. The value of order should be ascending or descending, or one of the short forms «asc» and «desc», or «reverse». An example is the following query for the three largest cities in Germany:

As explained in Help:Selecting pages, sorting conditions may impose restrictions on the set of query results. In the above case, only German cities that have a value for population are considered. If more than one property is used for sorting, the parameters sort and order can be set to lists of property names and orders, repsectively, separated by commas. The following is an example:

This query would return all German cities for which a state and population was specified. These results will be ordered by the name of the state they are located in (ordered alphabetically). Cities that are located in the same state will be ordered by their population, largest first («descending»).