{"id":197,"date":"2005-04-26T10:07:00","date_gmt":"2005-04-26T10:07:00","guid":{"rendered":"http:\/\/adam.rosi-kessel.org\/weblog\/free_software\/code\/randomsort.html"},"modified":"-0001-11-30T00:00:00","modified_gmt":"1970-01-01T05:00:00","slug":"randomsort","status":"publish","type":"post","link":"https:\/\/adam.rosi-kessel.org\/weblog\/2005\/04\/26\/randomsort","title":{"rendered":"Randomsort"},"content":{"rendered":"<p> I often need to randomly sort a file. I&#8217;m not aware of any standard bash or GNU command that does this, so I just wrote this very short script. There may be an even shorter\/faster\/more efficient way to do this, but I thought I&#8217;d post this as it might be helpful to a Linux newbie trying to accomplish the same task. Just put this in a file&#8212;e.g., &#8220;randomsort&#8221;; make it executable; and then pipe whatever you want to randomize into it (cat file_to_be_randomized | randomsort or randomsort file_to_be_randomized), and voila, you&#8217;re done. <\/p>\n<blockquote>\n<pre> &#35;!\/usr\/bin\/perl my @array = <>; while (@array) { my $element = int(rand(@array)); print $array[$element]; delete $array[$element]; } <\/pre>\n<\/blockquote>\n<p> Feel free to comment if you&#8217;ve got an easier solution. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I often need to randomly sort a file. I&#8217;m not aware of any standard bash or GNU command that does this, so I just wrote this very short script. There may be an even shorter\/faster\/more efficient way to do this, but I thought I&#8217;d post this as it might be helpful to a Linux newbie [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":0,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"wp:attachment":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}