From 0122ec18a92ad5a88ed60d9bac8397643d2a2eb5 Mon Sep 17 00:00:00 2001 From: Fayti1703 Date: Fri, 3 Apr 2026 12:57:56 +0200 Subject: [PATCH 1/2] Expand on how property order affects `#db` cursor `.sort()` --- docs/scripting/db/cursor/sort.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/scripting/db/cursor/sort.mdx b/docs/scripting/db/cursor/sort.mdx index c5ee74b7..cd3f010a 100644 --- a/docs/scripting/db/cursor/sort.mdx +++ b/docs/scripting/db/cursor/sort.mdx @@ -14,7 +14,12 @@ cursor.sort(sort) An object specifying the sort order, e.g. (( \{ n_hits: 1, n_fails: -1 \} )). Each key is the path of a sort key, each value specifies direction (((%V1%)) for ascending, ((%V-1%)) for descending). -Note that the order of keys in the object matters. +Note that the order of properties in the object directly affects the sort order: + +The sort object (( \{ n_hits: 1, n_fails: -1 \} )) sorts by ((%Nn_hits%)) ascending first, and only if two documents have identical ((%Nn_hits%)) values, sorts them by ((%Nn_fails%)) descending. +The sort object (( \{ n_fails: -1, n_hits: 1 \} )) does the opposite: it sorts by ((%Nn_fails%)) descending first, and only compares ((%Nn_hits%)) if ((%Nn_fails%)) on two documents is equal. + +(In JavaScript, 'regular' properties are ordered by creation order, with the first created property appearing first. Keep this in mind when dynamically building sort objects.) ### Return From 78253faa2618cd3d83503dba739f450fcc00984d Mon Sep 17 00:00:00 2001 From: matr1x <53655672+matr1x-hackmud@users.noreply.github.com> Date: Sat, 4 Apr 2026 20:34:45 +0100 Subject: [PATCH 2/2] Force-bump CLA