{"id":5,"date":"2008-06-11T20:57:29","date_gmt":"2008-06-11T18:57:29","guid":{"rendered":"http:\/\/floris.briolas.nl\/floris\/?p=5"},"modified":"2009-02-02T20:29:54","modified_gmt":"2009-02-02T19:29:54","slug":"unsorter","status":"publish","type":"post","link":"https:\/\/floris.briolas.nl\/floris\/2008\/06\/unsorter\/","title":{"rendered":"Unsorter"},"content":{"rendered":"<p>Today&#8217;s generic lists support sorting calls that can be modified to sort ascending or descending. How about a sort method that will just mangle the data. It may have uses for your TDD (UnitTest) related work.<\/p>\n<p>Here we go:<\/p>\n<pre name=\"code\" class=\"c#\">void Unsort()\r\n{\r\n    Random rnd = new Random();\r\n    List&lt;int&gt; myList = new List&lt;int&gt;();\r\n    for (int i = 0; i &lt; 100; i++)\r\n    {\r\n        myList.Add(i);\r\n    }\r\n     myList.Sort(\r\n        delegate(int a, int b)\r\n        {\r\n            if (a != b)\r\n                return rnd.Next(-1, 2);\r\n            return 0;\r\n        });\r\n}<\/pre>\n<p>Now your list is unsorted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s generic lists support sorting calls that can be modified to sort ascending or descending. How about a sort method that will just mangle the data. It may have uses for your TDD (UnitTest) related work. Here we go: void Unsort() { Random rnd = new Random(); List&lt;int&gt; myList = new List&lt;int&gt;(); for (int i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s61yPs-unsorter","_links":{"self":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/5"}],"collection":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":12,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/5\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}