GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

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: 4 Last Update: July 12, 2008     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: 15    

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


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape