Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Sat, 03 Oct 2026 04:38:18 -0700 Organization: A noiseless patient Spider Lines: 37 Message-ID: <8633unnhed.fsf@linuxsc.com> References: <1177fdi$26ea4$1@dont-email.me> <1736alhffrj7iuhfsesdo31bofc0m8pr12@4ax.com> <2026Sep11.083321@mips.complang.tuwien.ac.at> <6aa5876f.783937@news.eternal-september.org> <2026Sep12.201446@mips.complang.tuwien.ac.at> <6aa6172e.15711625@news.eternal-september.org> <2026Sep13.162747@mips.complang.tuwien.ac.at> <118h4cj$fi2a$1@dont-email.me> <118ltsc$26ss6$1@dont-email.me> <2026Sep19.175649@mips.complang.tuwien.ac.at> <118odha$31okp$1@dont-email.me> <86a4pct2oj.fsf@linuxsc.com> <119q3q8$36790$2@paganini.bofh.team> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sat, 03 Oct 2026 11:38:21 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3118693"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oIMy/RbYEDJI1cXYF3JjbibpUq2xeWU0="; posting-host="b0e28b4afc9fd8b2450f610d134fbfb4" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:L/DK/MDhTVQTEf84nXlHAMPVCx8= sha1:MMv8874NBUqTKFwBgzNhEFhyO9k= sha256:Zq65Uudix8o0f1Sn94tDJuAd1fVYrz32xlkiPCSUUUE= sha1:TNWJOFA5iXuBhC2281IrSSx0s8A= sha256:kzx9WIULHSLuhKq5R3v4g66DgznRq17utmIVQ2vmD+Q= Xref: csiph.com comp.arch:118422 antispam@fricas.org (Waldek Hebisch) writes: > Tim Rentsch wrote: > >> Thomas Koenig writes: >> >>> Bubblesort is the worst of non-joke sorting algorithms, see >>> the quote from Numerical Recipes... >> >> For people who don't like bubble sort, or for inclusion in a set >> of benchmarks, I suggest the following recently discovered >> sorting algorithm (written in C-ish pseudocode): >> >> void >> baffle_sort( unsigned n, int *elements ){ >> for( unsigned i = 0; i < n; i++ ){ >> for( unsigned j = 0; j < n; j++ ){ >> if( elements[i] < elements[j] ){ >> /* exchange elements[i] and elements[j] */ >> } >> } >> } >> } >> >> (Disclaimer: not original.) > > AFAICS this is very old "sorting by choice" algortim, I suggest you look again. It is not a selection sort. > just written > in inefficient way (using swaps and keeping running max in the > array instead of using extra variable). I am making no claim that this sort would be a good choice if one wanted an efficient algorithm. Surely no one would choose it on that basis. That's not what makes it interesting.