in reply to Re^2: sorting an array mix
in thread sorting an array mix
You can dodge the zeros issue and make it a bit more efficient using packYes, up to a point. It'll fail if one of the numbers exceed 4294967295 (2^32, the maximum number that will fit in an unsigned long).
It also assumes that all the strings start with the same letters, or that if they don't, the non-digit prefix is the secondary key; my solution assumes it's the primary key.
That is, given the list
your solution sorts it as:@g = qw [foo11 baz39 bar23 baz7 bar13 foo23];
and mine asbaz7 foo11 bar13 bar23 foo23 baz39
From the example the OP gives, it's not clear what he wants (or even whether the difference is relevant).bar13 bar23 baz7 baz39 foo11 foo23
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: sorting an array mix
by BrowserUk (Patriarch) on Oct 08, 2008 at 23:16 UTC |