in reply to Re: Sorting big text lists
in thread Sorting big text lists

foreach ( @lines ) { my @cells = split ; push @data, \@cells ; }

I wouldn't exactly be showing this to a newbie. As the original poster pointed out, he has "never even programmed", I have been using perl for about two years, and I still have some problems with references..

maybe building a hash with original lines as keys and specific column as values would be easier to understand (but maybe harder on the memory, depends on how big is the list.) don't you agree?


He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Re: Re: Sorting big text lists
by DamnDirtyApe (Curate) on Jul 31, 2002 at 15:16 UTC

    ++, though I tend to disagree regarding references. Your suggestion was to build a hash with original lines as keys, and a specific column as values. To me, that seems inefficient, and no easier to understand. The data is already in a tabular format. The operations we want to do (sorting by a specific column) are easily realized with tabular data. Why not, then, continue to treat the data as a table once it's loaded into memory? The only thing I might do differently here would be to use an AoH (array of hashes) instead of an AoA (array of arrays), thus giving the columns names instead of numbers.

    If I am wrong, and the code I presented is actually way over the original poster's head, forgive me. Here are some resources that will help:


    _______________
    D a m n D i r t y A p e
    Home Node | Email