Skip to content

Commit dccdc3b

Browse files
authored
Merge pull request github#6582 from github/smowton/admin/mention-multiple-sort-criteria
Expression docs: mention multiple sort criteria
2 parents e9ff6e8 + 303e02f commit dccdc3b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/codeql/ql-language-reference/expressions.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ based on the `Unicode value <https://en.wikipedia.org/wiki/List_of_Unicode_chara
201201
of each character.
202202

203203
To specify a different order, follow ``<expression>`` with the keywords ``order by``, then
204-
the expression that specifies the order, and optionally the keyword ``asc`` or ``desc``
204+
one or more comma-separated expressions that specify the order, and optionally the keyword ``asc`` or ``desc`` after each expression
205205
(to determine whether to order the expression in ascending or descending order). If you don't
206-
specify an ordering, it defaults to ``asc``.
206+
specify an ordering, it defaults to ``asc``. For example, ``order by o.getName() asc, o.getSize() desc``
207+
might be used to order some object by name, breaking ties by descending size.
207208

208209
The following aggregates are available in QL:
209210

@@ -229,11 +230,11 @@ The following aggregates are available in QL:
229230
In this case, ``<expression>`` must be of numeric type or of type ``string``.
230231

231232
For example, the following aggregation returns the name of the ``.js`` file (or files) with the
232-
largest number of lines:
233+
largest number of lines, using the number of lines of code to break ties:
233234

234235
.. code-block:: ql
235236
236-
max(File f | f.getExtension() = "js" | f.getBaseName() order by f.getTotalNumberOfLines())
237+
max(File f | f.getExtension() = "js" | f.getBaseName() order by f.getTotalNumberOfLines(), f.getNumberOfLinesOfCode())
237238
238239
The following aggregation returns the minimum string ``s`` out of the three strings mentioned
239240
below, that is, the string that comes first in the lexicographic ordering of all the possible

0 commit comments

Comments
 (0)