Subject: [PATCH 2/2] ui: Lexicographically sort transaction entries based on their package name.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 2 Sep 2020 13:22:16 -0400

* guix/ui.scm (show-manifest-transaction): Sort entries to be displayed in a
tabulated view.
---
 guix/ui.scm | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 01af3d93d3..e0d1dc1bb7 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1234,18 +1234,21 @@ separator between subsequent columns."
                                     #:key dry-run?)
   "Display what will/would be installed/removed from MANIFEST by TRANSACTION."
   (define* (package-strings names versions outputs #:key old-versions)
-    (tabulate (zip (map (lambda (name output)
-                          (if (string=? output "out")
-                              name
-                              (string-append name ":" output)))
-                        names outputs)
-                   (if old-versions
-                       (map (lambda (old new)
-                          (if (string=? old new)
-                              (G_ "(dependencies or package changed)")
-                              (string-append old " " → " " new)))
-                            old-versions versions)
-                       versions))
+    (tabulate (stable-sort
+               (zip (map (lambda (name output)
+                           (if (string=? output "out")
+                               name
+                               (string-append name ":" output)))
+                         names outputs)
+                    (if old-versions
+                        (map (lambda (old new)
+                               (if (string=? old new)
+                                   (G_ "(dependencies or package changed)")
+                                   (string-append old " " → " " new)))
+                             old-versions versions)
+                        versions))
+               (lambda (x y)
+                 (string<? (first x) (first y))))
               #:initial-indent 3))
 
   (define →                        ;an arrow that can be represented on stderr
-- 
2.27.0