my @array = ( 'a39e432b46dd245ab73ff64fc65b17497ec9ae3d date', 'a39e432b46dd245ab73ff64fc6asdfijijsdkksdjfks date2', 'a39e432b46dd245ab73ff64fc6asdfijijsdkksdjfks date3', ); my %hash = map{ reverse split / /, $_ }@array; for my $date ( sort keys %hash ){ print $date,"\n"; }