Sorting in AQL

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

AQL implements a default sort order, however, you can override the default and specify any other sort order using fields in your output by adding the .sort element to the end of your query as follows:

.sort({"<$asc | $desc>" : ["<field1>", "<field2>",... ]})

Note

You can only specify sorting on fields that are displayed in the output (whether they are those displayed by default or due to a .include element).

Here are some examples:

 // Find all the jars in artifactory and sort them by repo and name
 items.find({"name" : {"$match":"*.jar"}}).sort({"$asc" : ["repo","name"]})

 // Find all the jars in artifactory and their properties, then sort them by repo and name
items.find({"name" : {"$match":"*.jar"}}).include("@").sort({"$asc" : ["repo","name"]})