changeset 31938:29e0d557a3be stable

perms.m: Change "unique" output order to reverse lexicographic to match non-unique order (bug #63962) * perms.m: The documentation says "reverse lexicographic order" for the output but that was being met only for the inputs without "unique" specified. This edit makes them both comply with the documentation.
author Arun Giridhar <arungiridhar@gmail.com>
date Mon, 27 Mar 2023 13:04:03 -0400
parents c250c30c86a2
children 8e82a7fc21aa 7faaf2c6aaec
files scripts/specfun/perms.m
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/specfun/perms.m	Sat Mar 25 14:21:30 2023 -0700
+++ b/scripts/specfun/perms.m	Mon Mar 27 13:04:03 2023 -0400
@@ -57,12 +57,12 @@
 ## @group
 ## perms ([1, 1, 2, 2], "unique")
 ## @result{}
-##   1   1   2   2
-##   1   2   1   2
+##   2   2   1   1
+##   2   1   2   1
+##   2   1   1   2
 ##   1   2   2   1
-##   2   1   1   2
-##   2   1   2   1
-##   2   2   1   1
+##   1   2   1   2
+##   1   1   2   2
 ## @end group
 ## @end example
 ##
@@ -147,7 +147,7 @@
     [v, ~, j] = unique (v);
     h = accumarray (j, 1)';
     idx = m_perms (h);
-    P = v(sortrows (idx'));
+    P = v(sortrows (idx', -(1:rows(idx))));
   endif
 
 endfunction