in reply to How do I create a sort sub on-the-fly?

You don't need to write your own sort for this one. Data::Table does this for you.
#!/usr/bin/perl use strict; use Data::Table; my $t = Data::Table::fromCSV("data.csv", 0); # No header $t->sort(8,0,0, 0,1,0, 4,0,1, 2,0,1, 1,0,0); print $t->csv;
The parameters on the sort specify the column, sort direction, and numeric versus ascii sorting.

This produces output that agrees with yours.

It should work perfectly the first time! - toma

Replies are listed 'Best First'.
Re: Re: How do I create a sort sub on-the-fly?
by CharlesClarkson (Curate) on Nov 06, 2001 at 09:46 UTC

    Yes, I wrote one using Sort::Fields that was really short and quick. It seems that most new perl programmers don't like to use modules. Given a choice (and my student here had a choice), most neophytes will opt for the approach that doesn't involve installing a new module. Even after I explain that most modules don't require permission from a sys admin to install.




    Thanks for your reply,
    Charles K. Clarkson