in reply to Sorting path like strings
If your numeric values are all less than 255, then this works. You could swap the ST to a GRT or OM if performance is a concern. If your numbers get larger than 255 you could probably use unicode pack 'U*', but I haven't tested that.
@data = qw[ 0/1/2/3 0 0/4/5/6 0/4 0/1 0/1/2 0/4/5 0/10/111/145 0/10/111 0/10 ];; print for map{ $_->[0] } sort{ $a->[1] cmp $b->[1] } map{ [ $_, pack 'C*', split '/', ] } @data;; 0 0/1 0/1/2 0/1/2/3 0/4 0/4/5 0/4/5/6 0/10 0/10/111 0/10/111/145
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting path like strings
by arkturuz (Curate) on Jan 05, 2006 at 13:34 UTC | |
by BrowserUk (Patriarch) on Jan 05, 2006 at 13:37 UTC | |
by arkturuz (Curate) on Jan 05, 2006 at 13:48 UTC | |
|
Re^2: Sorting path like strings
by Aristotle (Chancellor) on Jan 05, 2006 at 13:47 UTC | |
by BrowserUk (Patriarch) on Jan 05, 2006 at 15:46 UTC |