emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/flx 813e56a014 115/182: Stabilise search results when scor


From: ELPA Syncer
Subject: [nongnu] elpa/flx 813e56a014 115/182: Stabilise search results when scores are equal.
Date: Tue, 13 Dec 2022 03:59:35 -0500 (EST)

branch: elpa/flx
commit 813e56a014eb9a929ad8a58142ee61a35f674276
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>

    Stabilise search results when scores are equal.
    
    - fixes #60
---
 flx-ido.el            |  9 ++++++++-
 misc/flx-helm-demo.el | 10 ++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/flx-ido.el b/flx-ido.el
index 7cb18b0efb..1b9648fdbd 100644
--- a/flx-ido.el
+++ b/flx-ido.el
@@ -178,7 +178,14 @@ If filtered item count is still greater than 
`flx-ido-threshold', then use flex.
                                  finally return matches)))
           (flx-ido-decorate (delete-consecutive-dups
                              (sort matches
-                                   (lambda (x y) (> (cadr x) (cadr y))))
+                                   (lambda (x y)
+                                     (let ((scorex (cadr x))
+                                           (scorey (cadr y))
+                                           (strx (car x))
+                                           (stry (car y)))
+                                       (if (= scorex scorey)
+                                           (not (string< stry strx))
+                                         (> scorex scorey)))))
                              t)))
       flex-result)))
 
diff --git a/misc/flx-helm-demo.el b/misc/flx-helm-demo.el
index 34fb4d17fe..417941270a 100644
--- a/misc/flx-helm-demo.el
+++ b/misc/flx-helm-demo.el
@@ -26,8 +26,14 @@ The score info we add here is later removed with another 
filter."
                                 (setcdr candidate (cons (cdr candidate) score))
                                 candidate)))
       (setq res (sort res
-                      (lambda (a b)
-                        (> (caddr a) (caddr b)))))
+                      (lambda (x y)
+                        (let ((scorex (caddr x))
+                              (scorey (caddr y))
+                              (strx (car x))
+                              (stry (car y)))
+                          (if (= scorex scorey)
+                              (not (string< stry strx))
+                            (> scorex scorey))))))
       (loop for item in res
             for index from 0
             for score = (cddr item)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]