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. my @arr = qw(hello world Show Must go on);

  2. print join(" ", sort {lc($b) cmp lc($a)} @arr), "

  3. ";

  4.  

Code
  1.         @array = qw( Udzial IS going Where means  How are Youu you share);

  2.         print join (" ", reverse(sort{lc($a) cmp lc ($b) } (@array)));

  3.      #  cmp used to do characters sort and

  4.      #  lc to do case insensitive

  5.      # 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