tag:blogger.com,1999:blog-1383695822029623916.post6020367990357530975..comments2024-03-28T00:20:38.908-04:00Comments on Chris Wong's Development Blog: On concisenessChristopher Wonghttp://www.blogger.com/profile/16941177380839071164noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-1383695822029623916.post-18026209332390932222009-11-16T13:22:54.116-05:002009-11-16T13:22:54.116-05:00Okay, I created a blog here to show the sample in ...Okay, I created a blog <a href="http://grannycode.blogspot.com/2009/11/quicksort-in-java.html" rel="nofollow">here</a> to show the sample in it's original formatting. Thanks for the suggestion!Georgehttps://www.blogger.com/profile/02433754573998619063noreply@blogger.comtag:blogger.com,1999:blog-1383695822029623916.post-42376347516383946952009-11-16T11:08:20.239-05:002009-11-16T11:08:20.239-05:00Thanks for catching the bug. In fact, I left out a...Thanks for catching the bug. In fact, I left out a line in the code (now fixed) that ends the recursion: "if (!list) return list". Without that line, the code in fact goes into infinite recursion. Oops. The fixed code will handle empty and null lists, as well as arrays.<br /><br />Unfortunately, Blogger is notorious for being source-code unfriendly. If you want to post a substantial Christopher Wonghttps://www.blogger.com/profile/16941177380839071164noreply@blogger.comtag:blogger.com,1999:blog-1383695822029623916.post-10296962187801257702009-11-16T09:42:33.099-05:002009-11-16T09:42:33.099-05:00(That looked a lot cleaner when it was formatted. ...(That looked a lot cleaner when it was formatted. Is there a way to preserve formatting when posting comments?)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1383695822029623916.post-72934485626589304032009-11-16T09:40:17.445-05:002009-11-16T09:40:17.445-05:00I'm afraid I don't know Groovy -- how does...I'm afraid I don't know Groovy -- how does the version shown deal with empty lists?<br /><br />Here's a somewhat cleaner java version:<br /><br /> List<Comparable> sort(List<Comparable> list) {<br /> ArrayList<Comparable> sorted = new ArrayList<Comparable>();<br /> ArrayList<Comparable> less = new ArrayList<Comparable>();<br />Anonymousnoreply@blogger.com