Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31658

Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements
Date Sat, 09 May 2015 07:58:31 -0400
Organization A noiseless patient Spider
Lines 18
Message-ID <miksnb$n9f$1@dont-email.me> (permalink)
References <c26476e6-86b7-494b-a2e8-4d9eb7f7bbd7@googlegroups.com> <mi8bp6$54r$1@gwaiyur.mb-net.net> <sorting-20150508234241@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 9 May 2015 11:57:32 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="23855"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QNSNyopaxxcPhr+rpVxss"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
In-Reply-To <sorting-20150508234241@ram.dialup.fu-berlin.de>
Cancel-Lock sha1:rFOkSpmE1e42zD8G2axiGJTK9b8=
Xref csiph.com comp.lang.java.programmer:31658

Show key headers only | View raw


On 5/8/2015 5:42 PM, Stefan Ram wrote:
> Marcel Mueller <news.5.maazl@spamgourmet.org> writes:
>> If you have no further information about the data to sort and you have
>> random access merge sort and its derivatives are probably best for
>> general purpose. Everything else depends.
>
>    If one has a huge array, it is well possible that the largest
>    possible gain comes from sorting an array of primitves (int)
>    versus an array of references (Integer).

     Note the many overloads of Arrays#sort() already provide for this:
There are versions not only for Objects, but for arrays of almost all
primitive types.  (Sorting an array of the remaining type is left as
an exercise for the reader; try for a linear-time implementation...)

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Ajay Paul <ajaykpaul@gmail.com> - 2015-05-04 10:39 -0700
  Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-05-04 19:54 +0200
    Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-09 07:58 -0400
  Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-04 14:16 -0400
    Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-04 14:27 -0400
  Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Martin Gregorie <martin@address-in-sig.invalid> - 2015-05-08 20:42 +0000
  Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements v_borchert@despammed.com (Volker Borchert) - 2015-05-11 02:32 +0000
  Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Gene Wirchenko <genew@telus.net> - 2015-05-11 14:00 -0700
    Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-11 17:27 -0400
    Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Arne Vajhøj <arne@vajhoej.dk> - 2015-06-03 21:53 -0400

csiph-web