Unsort Lines TextMate Command


/ Published in: Perl
Save to your folder(s)

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 ...


Copy this code and paste it in your HTML
  1. #!/usr/bin/perl -wl
  2.  
  3. @f=<>;
  4.  
  5. for $i (0 .. $#f) {
  6. $r=int rand ($i+1);
  7. @f[$i, $r]=@f[$r,$i] if ($i!=$r);
  8. }
  9.  
  10. chomp @f;
  11.  
  12. print join $/, @f;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.