Return to Snippet

Revision: 27491
at June 11, 2010 06:15 by heinz1959


Initial Code
#!/usr/bin/perl -wl

@f=<>;

for $i (0 .. $#f) {
	$r=int rand ($i+1);
	@f[$i, $r]=@f[$r,$i] if ($i!=$r);
}

chomp @f;

print join $/, @f;

Initial URL
http://www.commandlinefu.com/commands/view/4401/randomize-lines-opposite-of-sort

Initial Description
Need to "unsort" / randomize / scramble LINES in a text? Copy source -> then BBEdit -> File -> New -> Text Document -> paste source -> save as "Unsort Lines.pl" to ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/  --- done

Initial Title
Unsort Lines BBEdit Unix Filter

Initial Tags

                                

Initial Language
Perl