[padb-devel] [padb] r191 committed - Remove sortn completely, replacing it either with numeric sort...

codesite-noreply at google.com codesite-noreply at google.com
Sun Sep 6 10:18:47 BST 2009


Revision: 191
Author: apittman
Date: Sun Sep  6 02:17:40 2009
Log: Remove sortn completely, replacing it either with numeric sort
or plain old sort.

http://code.google.com/p/padb/source/detail?r=191

Modified:
  /branches/cleanup/src/padb

=======================================
--- /branches/cleanup/src/padb	Sun Sep  6 02:09:39 2009
+++ /branches/cleanup/src/padb	Sun Sep  6 02:17:40 2009
@@ -2054,16 +2054,6 @@
      debug_log( 'tree', $ref, 'Complete tree' );
      return _show_tree( $ref, undef, "" );
  }
-
-# sortn:
-#
-# # sort a group of alphanumeric strings by the last group of numerals in
-# that string
-#
-sub sortn {
-    map { $$_[0] }
-      sort { ( $$a[1] || 0 ) <=> ( $$b[1] || 0 ) } map { [ $_, /(\d*)$/ ]  
} @_;
-}

   
###############################################################################
  #
@@ -3203,7 +3193,8 @@
          }
      } else {
          my $nprocesses = keys %{ $d->{target_output} };
-        foreach my $process ( sortn( keys %{ $d->{target_output} } ) ) {
+        foreach my $process ( sort { $a <=> $b } keys %{  
$d->{target_output} } )
+        {
              foreach my $line ( @{ $d->{target_output}{$process} } ) {
                  if ( $nprocesses == 1 ) {
                      print "$line\n";
@@ -3382,7 +3373,7 @@

      debug_log( 'signon', undef, 'Received last signon, connecting to  
inner' );

-    @{ $comm_data->{host_ids} } = sortn( keys %{ $comm_data->{remote} } );
+    @{ $comm_data->{host_ids} } = sort keys %{ $comm_data->{remote} };
      $comm_data->{connection_tree} =
        generate_comm_tree( $comm_data->{host_ids} );

@@ -3578,7 +3569,7 @@
      my $ret = "\n";
      foreach my $name ( sort keys %{$td} ) {
          $ret .= "Namespace: \"$name\"\n";
-        foreach my $value ( sortn( keys %{ $td->{$name} } ) ) {
+        foreach my $value ( sort( keys %{ $td->{$name} } ) ) {
              $ret .= "    $value\t";
              $ret .= rng_convert_to_user( $td->{$name}{$value} ) . "\n";
          }
@@ -4383,7 +4374,7 @@
                  print "$r: ";
                  my @jobs = $rmgr{$res}{get_active_jobs}($user);
                  if ( $#jobs > -1 ) {
-                    my $j = join q{" }, sortn(@jobs);
+                    my $j = join q{" }, sort { $a <=> $b } @jobs;
                      print "jobs($j)\n";
                  } else {
                      print "No active jobs\n";




More information about the padb-devel mailing list