PokIsemaine commented on code in PR #2262:
URL: https://github.com/apache/kvrocks/pull/2262#discussion_r1590793723


##########
src/commands/cmd_key.cc:
##########
@@ -424,6 +424,115 @@ class CommandCopy : public Commander {
   bool replace_ = false;
 };
 
+template <bool ReadOnly>
+class CommandSort : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    CommandParser parser(args, 2);
+    while (parser.Good()) {
+      if (parser.EatEqICase("BY")) {
+        sort_argument_.sortby = GET_OR_RET(parser.TakeStr());

Review Comment:
   I try to test behavior like this in redis
   ```
   127.0.0.1:6379> lpush uid 1 3 2
   (integer) 3
   127.0.0.1:6379> mset uid_rank_1 3 uid_rank_2 2 uid_rank_3 1
   OK
   127.0.0.1:6379> mset uid_level_1 1 uid_level_2 2 uid_level_3 3
   OK
   127.0.0.1:6379> sort uid by uid_rank_*
   1) "3"
   2) "2"
   3) "1"
   127.0.0.1:6379> sort uid by uid_level_*
   1) "1"
   2) "2"
   3) "3"
   127.0.0.1:6379> sort uid by uid_level_* by uid_rank_*
   1) "3"
   2) "2"
   3) "1"
   127.0.0.1:6379> sort uid by uid_rank_* by uid_level_*
   1) "1"
   2) "2"
   3) "3"
   127.0.0.1:6379> sort uid by dontsort by uid_level_*
   1) "2"
   2) "3"
   3) "1"
   127.0.0.1:6379> sort uid by dontsort by uid_rank_*
   1) "2"
   2) "3"
   3) "1"
   127.0.0.1:6379> sort uid by uid_level_* by dontsort
   1) "2"
   2) "3"
   3) "1"
   127.0.0.1:6379> sort uid by uid_rank_* by dontsort
   1) "2"
   2) "3"
   3) "1"
   ```
   It seems that when multiple BY appears, the next value will prevail. If 
dontsort is included, the output will be according to dontsort. 
   Using multiple BYs does not seem like normal behavior, what do you think 
would be better? Align with redis or check?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to