Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand documentation on the ordering of lists and maps #771

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions modules/ROOT/pages/syntax/operators.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,14 @@ For example, `1 > b` and `1 < b` are both false when b is NaN.
*** xref::queries/expressions.adoc#boolean[`BOOLEAN`]
*** Numbers: xref::queries/expressions.adoc#numerical[`INTEGER`, `FLOAT`]
** The value `null` is ordered after all other values.
* *Ordering* of constructed type values:
** For the xref::values-and-types/property-structural-constructed.adoc#constructed-types[constructed types] (e.g. maps and lists), elements of the containers are compared pairwise for ordering and thus determine the ordering of two container types.
For example, `[1, 'foo', 3]` is ordered before `[1, 2, 'bar']` since `'foo'` is ordered before `2`.

* *Ordering* of xref::values-and-types/property-structural-constructed.adoc#constructed-types[constructed type] values:
** Lists are compared in dictionary order, also known as lexicographic order:
*** Elements are compared pairwise from the start of the list to the end. The order of the two lists is defined by the order of the first pair where the two elements differ. For example, `[1, 'foo', 3]` is less than `[1, 2, 'bar']` since `'foo'` is less than `2`.
*** If a list is shorter than the other one, it is padded with the empty element which is considered to be less than any other value (including null values). For example, `[1, 'foo']` is less than `[1, 'foo', 3]`, and `[1]` is less than `[1, null]`.
** Maps are ordered by size, keys, and values:
*** Maps are primarily compared by size: the smallest map is the one with the smallest number of entries. For example `{a: 1}` is less than `{a: 0, b: 'foo'}`.
*** The order of maps of equal size are then defined by comparing their respective lists of keys sorted in alphabetical order. For example `{b: 100, a: 'foo'}` is less than `{a: '', c: null}` since `['a', 'b']` is less than `['a', 'c']`.
*** Finally, the order of maps with identical key sets is based on comparing their values pairwise, having first sorted the entries by keys in alphabetical order. For example `{b: 100, a: 'foo'}` is less than `{a: 'foo', b: null}` since `['foo', 100]` is less than `['foo', null]`.

[[cypher-operations-chaining]]
=== Chaining comparison operations
Expand Down