in reply to Re: Algorithm Pop Quiz: Sorting
in thread Algorithm Pop Quiz: Sorting
Although I hadda go and use an xor swap, to make it look quite cool..sub sort_stack { local $depth = pop @stack; local $sort_depth = $depth; for (1..$depth) { for (1..$sort_depth) { local $top = pop @stack; local $next = pop @stack; if ($top gt $next) { $top ^= $next; $next ^= $top; $top ^= $next; } push @stack, $next, $top; rotate_up($sort_depth); } rotate_up($sort_depth); --$sort_depth; } push @stack, $depth; }
|
---|
Replies are listed 'Best First'. | |
---|---|
XOR swap bad...
by RMGir (Prior) on Mar 25, 2002 at 14:22 UTC | |
by Jasper (Chaplain) on Mar 25, 2002 at 14:51 UTC | |
by RMGir (Prior) on Mar 25, 2002 at 14:58 UTC | |
Re: Re: Re: Algorithm Pop Quiz: Sorting
by clintp (Curate) on Mar 25, 2002 at 15:18 UTC |