Path: csiph.com!2.eu.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.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:46:41 +0100 Organization: PointedEars Software (PES) Lines: 27 Message-ID: <1747065.xymvmi2RMH@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> <291513408.Ea4uQbgaIG@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1457477202 18292 eJwNyMkBwCAMA7CVAo5Nsw459h+B6ilCS3lclHM4tXLP2gbruJxsIevG+aj/E0C0t4oe5ux+Ht0RCA== (8 Mar 2016 22:46:42 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 8 Mar 2016 22:46:42 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBwDAEBMCVwvMYJxX2H6F3Dgo7jE7z9TUhQr6S0NkJ9eKzfHuRrazHL4/XpDNQwJWEUPNoj7UZfigwE/4= Cancel-Lock: sha1:ZpGn698YlmPcTXxm5wwU74Nqsfs= X-NNTP-Posting-Host: eJwNycEBADEEBMCWEMtpB9n+S8jNd3BCY9ID4SB496qSkG0xNq3WYj4fdv6RrurVWEGdqxYPMjURKg== Xref: csiph.com comp.lang.javascript:29862 Thomas 'PointedEars' Lahn wrote: > 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). > > Supplemental: JSX:array.js contains jsx.array.createComparator() which returns a reference to a custom comparator with which you can sort an array of (values convertible to) objects using their (then-)properties as sort keys. Test case, with link to the documentated source code: -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.