Return to Snippet

Revision: 27490
at June 11, 2010 06:06 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 TextMate Bundle Editor -> New Command -> select all in Command(s) -> paste source -> Input: Selected Text or Document -> Output: Replace Selected Text ...

Initial Title
Unsort Lines TextMate Command

Initial Tags
textmate

Initial Language
Perl