Folks, 
# How do I sort an array by one of it's fields? 

I have a this code: 

  for ($i=1; $i<=$N; $i++) {  }
       $dummy[$i][0] = &ParseDate($data{$key}[$i][0]);
        if (! $dummy[$i][0]) {  }
          warn "Could not parse $data{$key}[$i][0]\n";
         }
          $dummy[$i][1] = $data{$key}[$i][1];
              }
     &dumpdummy("Before sorting --", \@dummy);
   # Now we need to sort the # two columns of @dummy by # column 0 (date).
     @dummy2 = sort {     $a->[0]  cmp  $b->[0]    } @dummy; 
&dumpdummy("After sorting -- ", \@dummy2);
}

# @dummy before sorting has this: 

        1996013100:00:00        MAAA
        2000081100:00:00        MA-
        1997063000:00:00        MAAA
        1998122200:00:00        MAA
        2000112400:00:00        MD         


&dumpdummy is just a sub that writes the array in a nice way. 

I would like to sort by it by the first column, which is a date read by 
    ParseDate fron Date::Manip. 

    What am I doing wrong? How would it be done anyway? 

TIA, 
-tir











Reply via email to