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


Groups > comp.lang.javascript > #34230

Re: Sort at least 5 times faster then native and quicksort

Path csiph.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!feeder.erje.net!2.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Sort at least 5 times faster then native and quicksort
Date Sun, 29 Oct 2017 12:10:53 +0000
Organization A noiseless patient Spider
Lines 31
Message-ID <87d156upbm.fsf@bsb.me.uk> (permalink)
References <8c8816a1-0e4f-4bb4-8a52-94f434e4d599@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info reader02.eternal-september.org; posting-host="b252f5705e435813dbfff633d4cae81b"; logging-data="20802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rsr4rS7Ee9hAi2gU5vcdQhJaskAj0Bhg="
Cancel-Lock sha1:ID1w37Y+jLRC0NxNLk6UZzsSEEo= sha1:Xe+wwnzqyMbC38wONP9yTSqbEpM=
Xref csiph.com comp.lang.javascript:34230

Show key headers only | View raw


jonas.thornvall@gmail.com writes:

> My sort Algorithm is at least 5 time faster then native and quicks
> sort for densely populated samples "where numbers have 1 or more
> occurences".

It's not really your algorithm, it's your implementation of a well-known
algorithm.

> But usual there is some weird aspect i can't find out what i do wrong,
> if you set startrange for the random numbergererator higher then 0
> values will turn up undefined i don't get it.

You don't zero the right number of elements in countval.  This, in turn,
is because you do

  number=Math.floor(Math.random() * end) + start;

so the numbers range from start to start+end-1.

> But the timings are correct, 5 times faster for 100k of integers, and
> best of all the algorithm is linear, but it purely for sorting
> numbers.

Quoting a factor is not very helpful.  It's likely that you are doing
some form of counting sort, so you can make it any number of times
faster simply by sorting a larger set.  Equally, you can probably make
it lower by choosing a small set with a huge range.

-- 
Ben.

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


Thread

Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-28 21:27 -0700
  Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-28 21:41 -0700
  Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 03:53 -0700
    Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 04:33 -0700
  Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 04:37 -0700
  Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 12:10 +0000
    Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 05:53 -0700
      Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 06:01 -0700
      Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 14:47 +0000
        Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 08:13 -0700
          Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 15:46 +0000
            Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 08:49 -0700
              Re: Sort at least 5 times faster then native and quicksort Tim Streater <timstreater@greenbee.net> - 2017-10-29 16:16 +0100
            Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 08:52 -0700
            Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 08:58 -0700
              Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 16:18 +0000
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 09:36 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 09:48 -0700
                Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 18:02 +0000
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 20:51 -0700
                Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-30 09:31 +0000
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:14 -0700
                Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-30 10:31 +0000
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:35 -0700
                Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-30 14:19 +0000
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-11-02 14:38 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-11-02 14:42 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:44 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:50 -0700
                Re: Sort at least 5 times faster then native and quicksort Wally W. <ww84wa@aim.com> - 2017-10-30 06:40 -0400
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:48 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:32 -0700
                Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-30 03:37 -0700
        Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 08:35 -0700
    Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 06:07 -0700
      Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 14:37 +0000
    Re: Sort at least 5 times faster then native and quicksort jonas.thornvall@gmail.com - 2017-10-29 06:23 -0700
      Re: Sort at least 5 times faster then native and quicksort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-10-29 14:50 +0000

csiph-web