mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 08:35:22 +00:00
ts_simple_query_buffers: spell out that bloody sorting logic
This commit is contained in:
parent
c24f3564a2
commit
3954d53f2a
@ -292,10 +292,33 @@ sort_by(Data, OrderBy) ->
|
||||
F2 = element(C, R2),
|
||||
if F1 == F2 ->
|
||||
undefined; %% let fields of lower precedence decide
|
||||
F1 == [] andalso F2 /= [] ->
|
||||
Nul == "nulls first";
|
||||
F1 /= [] andalso F2 == [] ->
|
||||
Nul == "nulls last";
|
||||
|
||||
(F1 /= []) and (F2 == []) ->
|
||||
%% null < Value?
|
||||
case {Nul, Dir} of
|
||||
{"nulls first", "asc"} ->
|
||||
false;
|
||||
{"nulls first", "desc"} ->
|
||||
true;
|
||||
{"nulls last", "asc"} ->
|
||||
true;
|
||||
{"nulls last", "desc"} ->
|
||||
false
|
||||
end;
|
||||
|
||||
(F1 == []) and (F2 /= []) ->
|
||||
%% null > Value?
|
||||
case {Nul, Dir} of
|
||||
{"nulls first", "asc"} ->
|
||||
true;
|
||||
{"nulls first", "desc"} ->
|
||||
false;
|
||||
{"nulls last", "asc"} ->
|
||||
false;
|
||||
{"nulls last", "desc"} ->
|
||||
true
|
||||
end;
|
||||
|
||||
F1 < F2 ->
|
||||
(Dir == "asc");
|
||||
F1 > F2 ->
|
||||
|
Loading…
Reference in New Issue
Block a user