Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!tudelft.nl!txtfeed1.tudelft.nl!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!prichard.zen.co.uk.POSTED!not-for-mail Date: Thu, 01 Sep 2011 10:08:56 +0100 From: RedGrittyBrick User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Using Java Classes to Sort a Small Array Quickly References: <86c4a53b-1ca1-48a8-b954-c01bd449278a@s35g2000prm.googlegroups.com> In-Reply-To: <86c4a53b-1ca1-48a8-b954-c01bd449278a@s35g2000prm.googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Lines: 27 Message-ID: <4e5f4baa$0$2497$db0fefd9@news.zen.co.uk> Organization: Zen Internet NNTP-Posting-Host: cb4f7d7a.news.zen.co.uk X-Trace: DXC=ndEh9=8H;jXBoSkU<=5DDY0g@SS;SF6nWR9OH0:RnENT[FV[eonOiMVFJPo[XSAIjPICmGC6HSD@S X-Complaints-To: abuse@zen.co.uk Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7517 On 01/09/2011 03:48, KevinSimonson wrote: > I have an named that has twelve values. Today I > added an instance variable to it, a named. > The engineer I'm working with asked me to write a static method in > class that returns an array ofs sorted > alphabetically by this value. > > > is there a way in Java to > sort an array ofs (or perhaps more to the point to sort an > array ofs) that runs in O(N) time? Or even that runs in > O(N^2) time but faster than InsertionSort? I'd appreciate any > information anyone can give me on this. If I was sorting twelve elements, I would consider myself utterly deranged if I found myself worrying about the sort algorithm. If the static method will be called millions of times per second, you might want to cache the sort results rather than pointlessly repeating the sort, but only after measuring a performance problem and working out if this method really needs to be called that often. -- RGB