diff --git a/src/db.c b/src/db.c
index 7b34fcb47..a7cb4dbd3 100644
--- a/src/db.c
+++ b/src/db.c
@@ -2294,7 +2294,8 @@ int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
     keys = getKeysPrepareResult(result, 1);
     keys[0].pos = 1; /* <sort-key> is always present. */
     keys[0].flags = CMD_KEY_RO | CMD_KEY_ACCESS;
-    return 1;
+    result->numkeys = 1;
+    return result->numkeys;
 }
 
 /* Helper function to extract keys from the SORT command.
diff --git a/tests/unit/sort.tcl b/tests/unit/sort.tcl
index 7ef4fb1e5..d4927cf84 100644
--- a/tests/unit/sort.tcl
+++ b/tests/unit/sort.tcl
@@ -109,6 +109,10 @@ start_server {
     test "SORT extracts STORE correctly" {
         r command getkeys sort abc store def
     } {abc def}
+    
+    test "SORT_RO get keys" {
+        r command getkeys sort_ro abc
+    } {abc}
 
     test "SORT extracts multiple STORE correctly" {
         r command getkeys sort abc store invalid store stillbad store def