From: Jason Creighton Date: 2003-09-17T13:33:55+09:00 Subject: Re: scrambler one-liner On Tue, 16 Sep 2003 19:04:53 GMT "Mark J. Reed" wrote: > > On Wed, Sep 17, 2003 at 03:33:23AM +0900, Kurt M. Dresner wrote: > > Try > > > > -pe 'gsub!(/\B\w+\B/){$&.split(//).sort_by{rand}.join} > > > > Shorter (and even cleaner too!) > > It'll work with just sort instead of sort_by, won't it? > Save three characters! :) No, not quite. Sort will pass in two args and expect you to return -1, 0 or 1. So you could say enum.sort { rand(3)-1 } ...or.. enum.sort { rand() <=> 0.5 } ....but I don't know what evil effects having the comparison be random will have on a sorting algorithm. Best to stick with sort_by. Jason Creighton