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.

Questions by Namataraginu

Showing Answers 1 - 9 of 9 Answers

kglukhov

  • Jul 11th, 2008
 

@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";

  Was this answer useful?  Yes

ajit_saley

  • Jul 15th, 2009
 

@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);

  Was this answer useful?  Yes

j0eb0b

  • Oct 31st, 2009
 

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";

  Was this answer useful?  Yes

Matt LaSaine

  • May 29th, 2014
 


Code
  1. span style="color: #ff0000;">" ", sort {lc($b) cmp lc($a)} @arr), "

  2. ";

  3.  

Code
  1. span style="color: #ff0000;">" "#  cmp used to do characters sort and

  2.      #  lc to do case insensitive

  3.      # after sorting applied reverse on it

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions