Re: Sorting from subroutine call

2006-12-02 Thread Sergio Escalada
Yes! It was exactly what I was trying to do. I wasn't so wrong after all. Thanks you, Dani, your code helps me a lot :D 2006/12/2, D. Bolliger <[EMAIL PROTECTED]>: Sergio Escalada am Samstag, 2. Dezember 2006 15:41: > Thanks for replies. > > The purpouse of this mini-script is to list the rows

Re: Sorting from subroutine call

2006-12-02 Thread D. Bolliger
Sergio Escalada am Samstag, 2. Dezember 2006 15:41: > Thanks for replies. > > The purpouse of this mini-script is to list the rows from a database loaded > in memory ($ref_db is the reference to hashtable that cotains the DB). So I > want to order the fields by different sort rules, and make the pr

Re: Sorting from subroutine call

2006-12-02 Thread Sergio Escalada
# # hashref? Why in the WORLD is the database being kept in a hashref? # Oh, it's an exercise for class, and I must keep data in a hashtable, it's not my fault ^_^ Thanks for your code :) # # if you have a small number of columns you want to sort by, build a # simple subroutine to sort by

Re: Sorting from subroutine call

2006-12-02 Thread Mumia W.
On 12/02/2006 06:22 AM, Sergio Escalada wrote: Hi all! I would like to know if it's possible to make an array sorting with a subroutine call. Usually, a sort is made as, for example: sort {$a <=> $b} @array; But my intention is something like: sort subroutine_call @array; sub subroutine {

Re: Sorting from subroutine call

2006-12-02 Thread Lawrence Statton XE2/N1GAK
> The purpouse of this mini-script is to list the rows from a database loaded > in memory ($ref_db is the reference to hashtable that cotains the DB). So I > want to order the fields by different sort rules, and make the proccess as > abstract as it's possible with a subrutine (sub cmpRule). This s

Re: Sorting from subroutine call

2006-12-02 Thread Bill Jones
On 12/2/06, Sergio Escalada <[EMAIL PROTECTED]> wrote: The purpouse of this mini-script is to list the rows from a database loaded in memory ($ref_db is the reference to hashtable Another idea - sub sortrows { my $sorted = @_; $sorted = -(($a->{ahash} eq 'x') <=> ($b->{ahash} eq 'x')) if $

Re: Sorting from subroutine call

2006-12-02 Thread Sergio Escalada
Thanks for replies. The purpouse of this mini-script is to list the rows from a database loaded in memory ($ref_db is the reference to hashtable that cotains the DB). So I want to order the fields by different sort rules, and make the proccess as abstract as it's possible with a subrutine (sub cm

Re: Sorting from subroutine call

2006-12-02 Thread Rob Dixon
Sergio Escalada wrote: Hi all! I would like to know if it's possible to make an array sorting with a subroutine call. Usually, a sort is made as, for example: sort {$a <=> $b} @array; But my intention is something like: sort subroutine_call @array; sub subroutine { $a <=> $b; } How cou

Re: Sorting from subroutine call

2006-12-02 Thread Rob Dixon
Sergio Escalada wrote: Hi all! I would like to know if it's possible to make an array sorting with a subroutine call. Usually, a sort is made as, for example: sort {$a <=> $b} @array; But my intention is something like: sort subroutine_call @array; sub subroutine { $a <=> $b; } How cou

Re: Sorting from subroutine call

2006-12-02 Thread Lawrence Statton XE2/N1GAK
> Hi all! I would like to know if it's possible to make an array sorting with > a subroutine call. > > Usually, a sort is made as, for example: > > > sort {$a <=> $b} @array; > > > But my intention is something like: > > > sort subroutine_call @array; > > sub subroutine > { > $a <=> $b; > }

Re: Sorting from subroutine call

2006-12-02 Thread W.P.Nijhof
Sergio Escalada wrote: Hi all! I would like to know if it's possible to make an array sorting with a subroutine call. Usually, a sort is made as, for example: sort {$a <=> $b} @array; But my intention is something like: sort subroutine_call @array; If you really want to call it like this