Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Tedious array sort revisited

by gatornek (Initiate)
on Feb 05, 2003 at 18:54 UTC ( [id://232890]=note: print w/replies, xml ) Need Help??


in reply to Re: Tedious array sort revisited
in thread Tedious array sort revisited

Thank you for your help. I WAS trying to find a way to use the power of the foreach structure, but you showed me the error of my ways. Would it be better to say something like this:
for (i = 0, i =< @#entries, i++) { $indexofleast = i; for (j = 1, j =< @#entries, j++) { if (@entries[j] lt @entries[i]) { $indexofleast = j; } if ($indexofleast != i) { $temp = @array[j]; $@array[j] = $@array[i]; $@array[i] = $temp; } } }
Thanks for anymore help I can get. I stress that I am brand new to perl (so I'm really not sure if I'm using the @# operator correctly). This is supposed to work on single character strings and sort them.

Replies are listed 'Best First'.
Re: Re: Re: Tedious array sort revisited
by zakb (Pilgrim) on Feb 06, 2003 at 11:08 UTC

    Close. I think you want $#entries, $array[i] and $array[j].

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-18 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found