Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Data Structures wanted; apply within.

by DeaconBlues (Monk)
on Mar 09, 2001 at 22:19 UTC ( [id://63291]=note: print w/replies, xml ) Need Help??


in reply to Data Structures wanted; apply within.

On CPAN there is a module Sort::Fields which sorts arrays of strings which are delimited into fields. I have been thinking of using this as a base for another module which sorts strings with fixed-width fields instead of delimited fields.

You can help make this for me!?!?

  • Comment on Re: Data Structures wanted; apply within.

Replies are listed 'Best First'.
Re: Re: Data Structures wanted; apply within.
by jeroenes (Priest) on Mar 09, 2001 at 22:29 UTC
    Sure:
    @sorted = sort{ substr($a,$pos,$length) cmp substr($b,$pos,$length)} @list;
    It's no module, but it works...

    Hope this helps,

    Jeroen
    "We are not alone"(FZ)

      Thanks, but the power of the module is that it allows your to sort on any number of columns. For example:
      first sort on substr($string, $foo0, $bar0), then
      then sort on substr($string, $foo1, $bar1) , then
      then sort on substr($string, $foo2, $bar2) , ... and so on.

        If you take a look at sort, you see that you can do something like
        sub deepsort { substr( $_[0], $p[0], $l[0]) cmp substr( $_[1], $p[0], $l[0] ) || substr( $_[0], $p[1], $l[1]) cmp substr( $_[1], $p[1], $l[1] ) || ....ad nauseum } @sorted = sort 'deepsort', @list;
        Of course it's better to build the deepsort from an eval and map.....

        Jeroen
        "We are not alone"(FZ)

Re: Re: Data Structures wanted; apply within.
by Falkkin (Chaplain) on Mar 09, 2001 at 22:24 UTC
    I can look into it... presently, I'm looking into writing some patches for Net::Ping, because that appears to be a major module that needs help, but I'll keep your suggestion in mind. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63291]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found