GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  Perl
Go To First  |  Previous Question  |  Next Question 
 Perl  |  Question 55 of 61    Print  
Print this array, sorted in reversed case-insensitive order...
You have unsorted array of strings, like:
my @arr = qw(hello World Show must go on);
Print this array, sorted in reversed case-insensitive order.




  
Total Answers and Comments: 6 Last Update: November 01, 2009     Asked by: Namataraginu 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 06, 2008 05:22:25   #1  
akmails23 Member Since: February 2008   Contribution: 1    

RE: Print this array, sorted in reversed case-insensitive order...
@solution sort { lc $a cmp lc $b } @arr;This will give the required solution.Thanks Kalai
 
Is this answer useful? Yes | No
May 02, 2008 07:49:30   #2  
wow_suraj Member Since: May 2008   Contribution: 22    

RE: Print this array, sorted in reversed case-insensitive order...
my @arr qw(hello World Show must go on);
@arr reverse sort(@arr);

foreach (@arr)
{
print "+---|$_|----+n";
}

This code will give you the reverse sort array.

 
Is this answer useful? Yes | No
June 10, 2008 02:48:13   #3  
rahulashu Member Since: June 2008   Contribution: 4    

RE: Print this array, sorted in reversed case-insensitive order...

#! /bin/perl

@array ("b" "f" "n" "m");

@array ( reverse ( sort(@array) ) );

print "@arrayn" ;


 
Is this answer useful? Yes | No
July 11, 2008 17:04:50   #4  
kglukhov Member Since: July 2008   Contribution: 2    

RE: Print this array, sorted in reversed case-insensitive order...
@x qw(A d E f B c x Y);
print "Original arrayn";
print join(' ' @x) "n";
print "Original array sorted in reverse order case insensitiven";
print join(' ' sort {"L$b" cmp "L$a"} @x) "n";

 
Is this answer useful? Yes | No
July 15, 2009 12:54:59   #5  
ajit_saley Member Since: February 2009   Contribution: 5    

RE: Print this array, sorted in reversed case-insensitive order...

@arr qw(ajit satish AJIt amartya maku);

foreach my $ele (@arr)

{

push (@new_arr lc($ele));

}

print "n new arr @new_arr";

@rev_arr reverse sort(@new_arr);


 
Is this answer useful? Yes | No
October 31, 2009 18:09:37   #6  
j0eb0b Member Since: October 2009   Contribution: 1    

RE: Print this array, sorted in reversed case-insensitive order...
my @arr qw(hello World Show must go on);

#close
print "@arr nreverse sorted: " join(" " reverse sort map {lc $_} @arr) "n";

#closer
print "@arr nreverse sorted: " join(" "
map { $_->[0] }
sort { $b->[1] cmp $a->[1] }
map { [$_ lc $_] }
@arr) "n";

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape