Dave's Brain

Browse - Programming Tips - How can I do a case-insensitive sort?

Date: 2012mar20
Language: perl

Q.  How can I do a case-insensitive sort?

A.  

sub sortNoCase(@) { my(@a) = @_; return sort {lc $a cmp lc $b} @a; } # Example use: @sorted = sortNoCase(@messy);

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.