Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Bubblesort Date: Tue, 08 Mar 2016 23:34:18 +0100 Organization: PointedEars Software (PES) Lines: 28 Message-ID: <291513408.Ea4uQbgaIG@PointedEars.de> References: <0d68ee6d-8a80-439e-ae04-17743584e2e4@googlegroups.com> <086a7397-459b-46e3-b83c-cfc7edf4188a@googlegroups.com> <7b1ee9db-4732-48e1-be7e-37ba62db4c6e@googlegroups.com> <26b2b860-b6c6-40ff-bcf6-64d6a9baa55e@googlegroups.com> <8737s6doyh.fsf@bsb.me.uk> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1457476459 15573 eJwNxkcBwEAIBEBL1IXYofmXcJnXuILRYXCYnx9IZeQr9dow+ou8wvAS5xjpyDRHpzrtqT0MhhCY (8 Mar 2016 22:34:19 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 8 Mar 2016 22:34:19 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBACAIBLBKgLxxELz+EdzsOPuEurkaDAeFGs2FGMe2ZEntpdY3TrefSkw32VLAKZ/1wYQTM1qQH2RQFe8= Cancel-Lock: sha1:BX5D1R/7enWF9KlCpDBQUIhUQLE= X-NNTP-Posting-Host: eJwFwQkBwDAIA0BL5UkAOYMV/xJ6B6Nwwgk6FpuT3vyiwu+/qWbCGxMN1hEfQoljppis0/0AC6QQIQ== Xref: csiph.com comp.lang.javascript:29860 Ben Bacarisse wrote: > jonas.thornvall@gmail.com writes: > >> Sorry i bothered you your approach do indeed ***work***, apparently it >> is a string but i can't understand how random makes a string value. > > Math.random() does not make a string but Array.prototype.sort() uses > string comparison by default. It's documented. Imprecise. String comparison *can* be the default for Array.prototype.sort(); in fact, if the /comparefn/ argument is “undefined” (including not specified), the sort order is *implementation-dependent*. Implementations need not agree on a default comparator. So specifying a comparator is *required* in *portable* code *regardless* of the type of the elements (which can be of a different type each; but see Typed Arrays). -- PointedEars Zend Certified PHP Engineer | Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.