]> git.proxmox.com Git - pve-common.git/commitdiff
cli: print_text_table: default to autosort on
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Jun 2018 09:23:25 +0000 (11:23 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 27 Jun 2018 09:23:31 +0000 (11:23 +0200)
we more often want to sort by the leftmost valid column than not.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLIHandler.pm

index 414caa5d8c25ee4835ef7d1756e69fa98a2f144e..9cf79886acc009953dd35e130c2329bddf1553f3 100644 (file)
@@ -445,15 +445,15 @@ sub data_to_text {
 # $data - the data to print (array of objects)
 # $returnprops -json schema property description
 # $props_to_print - ordered list of properties to print
 # $data - the data to print (array of objects)
 # $returnprops -json schema property description
 # $props_to_print - ordered list of properties to print
-# $sort_key is either a column name, or integer 1 which simply
-# sorts the output according to the leftmost column not containing
-# any undef. if not specified, we do not change order.
+# $sort_key can be used to sort after a column, if it isn't set we sort
+#   after the leftmost column (with no undef value in $data) this can be
+#   turned off by passing 0 as $sort_key
 sub print_text_table {
     my ($data, $returnprops, $props_to_print, $sort_key) = @_;
 
 sub print_text_table {
     my ($data, $returnprops, $props_to_print, $sort_key) = @_;
 
-    my $autosort = 0;
-    if (defined($sort_key) && ($sort_key eq 1)) {
-       $autosort = 1;
+    my $autosort = 1;
+    if (defined($sort_key) && $sort_key eq 0) {
+       $autosort = 0;
        $sort_key = undef;
     }
 
        $sort_key = undef;
     }