How to sort dates in Perl ?



How to sort dates in Perl ?..

Answer / kiruthikau

Try the following way.
Example
-------
use Data::Dumper;
my @dates = ( "02/11/2009" , "20/12/2001" , "21/11/2010" ) ;
@dates = sort { join( '', (split '/', $a)[2,1,0] ) cmp
join( '', (split '/', $b)[2,1,0]) } @dates;
print Dumper \@dates;

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"

0 Answers   Cisco, Oracle,


What does next statement do in perl?

0 Answers  


How to copy a file in perl?

0 Answers  


Explain chomp, chop, cpan, tk.

0 Answers  


What is the difference between use and require in perl programming?

0 Answers  


Explain the difference between my and local?

2 Answers  


What is the difference between perl list and perl array?

0 Answers  


what is the procedure to define a user define module in your perl application?

2 Answers   IBM,


What is perl shift array function?

0 Answers  


How would you ensure the re-use and maximum readability of your perl code?

0 Answers  


You want to concatenate strings with perl. How would you do that?

0 Answers  


What does this symbol mean '->'?

0 Answers  


Categories