Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Date: Mon, 04 May 2015 14:16:40 -0400 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 4 May 2015 18:15:38 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="4879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RK5c3ikj+JR/9menThyuC" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: Cancel-Lock: sha1:ICKMgLMAkwUOkRub8tNihml9EO0= Xref: csiph.com comp.lang.java.programmer:31649 On 5/4/2015 1:39 PM, Ajay Paul wrote: > what are the best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements. See Marcel Muller's response. As a practical matter, use java.util.Collections#sort or java.util.Arrays#sort and apply your ingenuity to the other problems your program needs to solve. Later on, if you measure the performance, find it inadequate, discover that sorting is a significant time-waster, *and* think you can do better -- if all those, then and only then implement your own sort. > I understand that bubble short is worst. Not even close. One well-known far worse sort is https://en.wikipedia.org/wiki/Bogosort ... and of course any implementation of any algorithm can always be disimproved. (One effective way is to post the bad code to Usenet and solicit improvements ;) -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM