#!/usr/bin/perl -w
#
my @personnes;
my ($nom,$prenom,$age,$tri);

do 
{
print "\nTRIER EN FONCTION DE: (nom/prenom/age)\n";
chomp($tri = <STDIN>);

}
until ($tri =~ /^nom|prenom|age$/);

if ($tri =~ /prenom/) { $tri = 1; }
elsif ($tri =~ /nom/) { $tri = 0; }
else {$tri = 2; }


open(INFO,"fichier")  or die("Fichier inexistant");
while (<INFO>)
{	
	($nom,$prenom,$age) = split(":");
	push (@personnes,"$nom $prenom $age");
}

@personnes = 
sort { (split " " , $a )[$tri] cmp
        (split " " , $b )[$tri]
	} @personnes;
print @personnes;



