in reply to sorting by field of a tab-delimited hash value
use strict; use warnings; my %students = ( 0354 => "Fred\t3.2", 4873 => "Tom\t2.9", 4874 => "Bill\t2.9", 1522 => "Susan\t4.0", ); $_ = [split /\t/, $_] for values %students; print "$students{$_}[0] (#$_} $students{$_}[1]\n" for sort { $students{$b}[1] <=> $students{$a}[1] || $students{$a}[0] cmp $students{$b}[0] } keys %students;
|
|---|