lemming has asked for the wisdom of the Perl Monks concerning the following question:
Someone asked in the CB how to sort alphabetically, but to have all items beginning with "X" to be listed first.
My solution:@arr = sort { ("X" eq substr($b,0,1)) <=> ("X" eq substr($a,0,1)) or $a cmp $b} @arr;
Very simplistic and note this is in ASCII order not true alpa. For that apply lc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A CB Sorting Question
by runrig (Abbot) on Dec 07, 2000 at 05:24 UTC | |
|
Re: A CB Sorting Question
by boo_radley (Parson) on Dec 07, 2000 at 05:13 UTC |