my @a = ( [4129290, 1675967, 2412031, '41%', '/usr/bin' ], [4129290, 1675967, 2412031, '41%', '/usr' ], [4129290, 1675967, 2412031, '41%', '/local' ], ); sorter(@a); __END__ output ====== before sort: /local Sorted by drive: /usr/bin #### my @df_k = split(/\n/, `df -k`); shift(@df_k); # Remove header. my @sorted_by_drive = sort { $a->[5] cmp $b->[5] } map { [ split(/\s+/, $_, 6) ] } @df_k; use Data::Dumper (); print(Data::Dumper->Dump( [ \@sorted_by_drive ], [qw( $sorted_by_drive )], )); #### sub parseIntoArraySolaris (@df) ^^ what does this mean? It compiles, surprisingly, but it's not listed in docs and it doesn't give the args to the var @df. #### sub parseIntoArraySolaris { my @rows; my $element; foreach $element (@_) { my ($a, $b, $c, $d, $e, $f) = split(/\s+/, $element); push(@rows, [ $b/1024, $c/1024, $d/1024, $e, $f ]); } return @rows; } #### sub parseIntoArraySolaris { return map { my ($a, $b, $c, $d, $e, $f) = split(/\s+/, $_); [ $b/1024, $c/1024, $d/1024, $e, $f ] } @_; } #### my @df_k = split(/\n/, `df -k`); shift(@df_k); # Remove header. my @beforeSort = parseIntoArraySolaris(@df_k); my @sorted_by_drive = sort { $a->[4] cmp $b->[4] } @beforeSort; use Data::Dumper (); print(Data::Dumper->Dump( [ \@sorted_by_drive ], [qw( $sorted_by_drive )], )); #### # Get data. my @df_k = split(/\n/, `df -k`); # Remove header. shift(@df_k); # Parse line. foreach (@df_k) { my ($a, $b, $c, $d, $e, $f) = split(/\s+/, $_); $_ = [ $b/1024, $c/1024, $d/1024, $e, $f ]; } # Sort. my @sorted_by_drive = sort { $a->[4] cmp $b->[4] } @df_k; # Quick way of printing for now. use Data::Dumper (); print(Data::Dumper->Dump( [ \@sorted_by_drive ], [qw( $sorted_by_drive )], ));