Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mike Amling Newsgroups: comp.lang.java.programmer Subject: Re: Help with java insertion sort program Date: Wed, 13 Aug 2014 23:51:44 -0500 Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net NTiGBtb/T/1GNb93dLpSzw3ezeSRmyByj7bghqiRx/Daiz9HbH Cancel-Lock: sha1:MbdhMxSqG4iwVGBI0Mmq5HZEN6w= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:29658 On 8/10/14 6:43 AM, Eric Sosman wrote: > On 8/10/2014 7:09 AM, Mike Amling wrote: >> On 8/9/14 9:11 PM, Scott Dunning wrote: >>> Hello I trying write a sorting program that will ask a user what type of >>> sorting method to use (insertion, bubble, selection) and then ask them >>> to enter integers to sort. >> >> One wonders why classes are still teaching these algorithms. I've had >> colleagues who have written bubble sort into production code, because >> that's the only algorithm they were ever taught (or maybe it was better >> than some even worse ones). >> >> If you do complete this assignment, throw away the code, look up >> QuickSort, implement a reasonable variation of it, and don't look back. > > Better still, look up Arrays.sort() and Collections.sort() and > throw away your Quicksort implementation. How do you get Arrays.sort to sort primitives descending? What if you want to, say, apply the same permutation to the elements of array Y that sorting applies to the elements array X? --Mike Amling VG8gc29ydCBpbnRbXSB4IGRlc2NlbmRpbmcsIHJlcGxhY2UgZXZlcnkgZWxlbWVudCB4W2pdIHdp dGggLTEteFtqXSBhbmQgY2FsbCBBcnJheXMuc29ydCh4KSwgdGhlbiBhZ2FpbiByZXBsYWNlIGV2 ZXJ5IHhbal0gd2l0aCAtMS14W2pdLg==