Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Sorting case insensitively

Reply
Thread Tools

Sorting case insensitively

 
 
John Deuf
Guest
Posts: n/a
 
      10-27-2003
Is there a way to sort case insensitively an array (without creating
another array with lowercase values for instance) ?
 
Reply With Quote
 
 
 
 
Andreas Kahari
Guest
Posts: n/a
 
      10-27-2003
In article <(E-Mail Removed)> , John Deuf wrote:
> Is there a way to sort case insensitively an array (without creating
> another array with lowercase values for instance) ?



sort { uc($a) cmp uc($b) } @arr;



--
Andreas Kähäri
 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      10-27-2003
>>>>> "AK" == Andreas Kahari <(E-Mail Removed)> writes:

AK> sort { uc($a) cmp uc($b) } @arr;

>>>>> "BE" == Bernard El-Hagin <(E-Mail Removed)> writes:

BE> my @sorted = sort { lc $a cmp lc $b } @unsorted;

now make up your minds!! which one of those is better? will there be
another war on uc vs lc?



uri

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      10-27-2003

Uri Guttman <(E-Mail Removed)> wrote:
> >>>>> "AK" == Andreas Kahari <(E-Mail Removed)> writes:

>
> AK> sort { uc($a) cmp uc($b) } @arr;
>
> >>>>> "BE" == Bernard El-Hagin

> <(E-Mail Removed)> writes:
> BE> my @sorted = sort { lc $a cmp lc $b } @unsorted;
>
> now make up your minds!! which one of those is better? will there be
> another war on uc vs lc?


I thought there was a Right Answer to this: lc, as Unicode defines
mappings upper -> lower and title -> lower...?

Ben

--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * (E-Mail Removed)
 
Reply With Quote
 
Master Web Surfer
Guest
Posts: n/a
 
      10-31-2003
[This followup was posted to comp.lang.perl.misc]

In article <(E-Mail Removed)> ,
(E-Mail Removed) says...
> Is there a way to sort case insensitively an array (without creating
> another array with lowercase values for instance) ?



@sorted = sort { uc($a) cmp uc($b) } @data;

# Note that you could also use "lc" instead of "uc" in
# the sorting specification
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 6.6 How do I substitute case insensitively on the LHS while preserving case on the RHS? PerlFAQ Server Perl Misc 0 02-08-2011 05:00 PM
Re: How to check a String contains another String,case-insensitively? tomaszewski.p Java 4 09-12-2008 05:40 PM
Re: How to check a String contains another String, case-insensitively? Roedy Green Java 0 09-12-2008 04:26 PM
Re: How to check a String contains another String, case-insensitively? Knute Johnson Java 0 09-11-2008 07:59 PM
Sorting a List of Objects by an Attribute of the ObjectsCase-Insensitively Jason Python 5 04-09-2008 11:51 PM



Advertisments