You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2026/09/22 21:53:28 UTC
(couchdb) branch nouveau-string-sorting created (now 182b4f72f)
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a change to branch nouveau-string-sorting
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 182b4f72f fix nouveau string sorting order
This branch includes the following new commits:
new 182b4f72f fix nouveau string sorting order
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(couchdb) 01/01: fix nouveau string sorting order
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-string-sorting
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 182b4f72f2e102d572302b44e66d560662203d6d
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Sep 22 22:52:57 2026 +0100
fix nouveau string sorting order
Match Java's string sorting order (lexicographical)
---
src/nouveau/src/nouveau_fabric_search.erl | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/nouveau/src/nouveau_fabric_search.erl b/src/nouveau/src/nouveau_fabric_search.erl
index 066171465..f954a8ac6 100644
--- a/src/nouveau/src/nouveau_fabric_search.erl
+++ b/src/nouveau/src/nouveau_fabric_search.erl
@@ -203,21 +203,23 @@ compare_order(null, As, Bs) ->
%% server-side adds _id on the end of sort order if not present
compare_order([], [A], [B]) ->
couch_ejson_compare:less(convert_item(A), convert_item(B)) < 1;
+compare_order(Order, [#{} = A | ARest], [#{} = B | BRest]) ->
+ compare_order(Order, [convert_item(A) | ARest], [convert_item(B) | BRest]);
%% reverse order specified
compare_order([<<"-", _/binary>> | SortRest], [A | ARest], [B | BRest]) ->
- case couch_ejson_compare:less(convert_item(B), convert_item(A)) of
- 0 ->
+ if
+ A == B ->
compare_order(SortRest, ARest, BRest);
- Less ->
- Less < 1
+ true ->
+ B < A
end;
%% forward order specified
compare_order([_ | SortRest], [A | ARest], [B | BRest]) ->
- case couch_ejson_compare:less(convert_item(A), convert_item(B)) of
- 0 ->
+ if
+ A == B ->
compare_order(SortRest, ARest, BRest);
- Less ->
- Less < 1
+ true ->
+ A < B
end.
convert_item(Item) ->