in reply to Re: Rolling DND Dice.
in thread Rolling DND Dice.

See, I was going to use sort to get the highest three values, but sort slaps together repeated values, so that sort(1,3,3,7) gives (1,3,7). Is there some way around this? I think there's a pragma to make sort use a stable method (which would have the side effect of not deleting dupes?), but it's in 5.8, and I'm using 5.6 here. (Old, old distribution which desperately needs an upgrade.)

Replies are listed 'Best First'.
Re: Re: Re: Rolling DND Dice.
by blokhead (Monsignor) on Feb 04, 2004 at 04:27 UTC
    Huh?
    $ perl -e 'print join " ", sort 1,1,1,3,3,7' 1 1 1 3 3 7
    Unstable sorting means input order isn't preserved for ties, not that stuff is removed. By your reasoning, sort { 0 } @array would just return one element every time, since all the items are tied in sorting order.

    blokhead