baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
here is my problem i have a series of indexes which i would like to sort, but using this code :
the result is : St1 St10 St12 St2 St6 St8 but what i need is :use strict; my @g = qw(St1 St10 St2 St12 St6 St8); my @b = sort{$a cmp $b} @g; foreach my $x (@b){ print "$x\n"; }
St1 St2 St6 St8 St10 St12
i mean i don't know how to sort a set of strings that have numbers in it . i mean i understand why this isn't working by the method i used but if any one has any suggestions on how to overcome this problem ...
thanx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sorting an array mix
by salva (Canon) on Oct 08, 2008 at 15:22 UTC | |
|
Re: sorting an array mix
by Fletch (Bishop) on Oct 08, 2008 at 15:24 UTC | |
|
Re: sorting an array mix
by FunkyMonk (Bishop) on Oct 08, 2008 at 21:55 UTC | |
|
Re: sorting an array mix
by JavaFan (Canon) on Oct 08, 2008 at 15:35 UTC | |
by BrowserUk (Patriarch) on Oct 08, 2008 at 15:59 UTC | |
by JavaFan (Canon) on Oct 08, 2008 at 19:31 UTC | |
by BrowserUk (Patriarch) on Oct 08, 2008 at 23:16 UTC |