SPUG: Sort an array question
Michael R. Wolf
MichaelRunningWolf at att.net
Fri Dec 27 04:43:31 CST 2002
William Julien <moonbeam at catmanor.com> writes:
[...]
> $tmp = $array[$j]; # save element
> $array[$j] = $array[$i]; # swap
> $array[$i] = $tmp; # restore element
Or, use a slice to do 3 steps in one, without need for a $tmp:
@array[$i, $j] = @array[$j, $i];
This was one of the first really cool shadows of the bigger Perl
animal that made me realize it's a complex beast. It does DWIM!!!
--
Michael R. Wolf
All mammals learn by playing!
MichaelRunningWolf at att.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list