@lines = map { /(\/\w+\/\w+)\s+\w+\s+\d+\s+\d+\s+(\d+)\s+(\d+)%/; { volume => $1, available => $2, free => 100 - $3, } } split /\n/, $space{ $host }; # This is the sorting line! @lines = sort { $a->{available} <=> $b->{available} } @lines; push @out, "$host:$_->{volume} $_->{available} $_->{free}%" for @lines;