Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Baby X is bor nagain
Date: Thu, 20 Jun 2024 22:34:02 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <86tthmhnat.fsf@linuxsc.com>
References: <20240613174354.00005498@yahoo.com> <20240617002924.597@kylheku.com> <20240618115650.00006e3f@yahoo.com> <20240618184026.000046e1@yahoo.com> <877celzx14.fsf@nosuchdomain.example.com> <87iky3svqh.fsf@bsb.me.uk> <86y16zhcy3.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 21 Jun 2024 07:34:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b1207652c594f8095021b04518fba685"; logging-data="3184435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1833Mc113zpByOUvudt7ynAj6gsJArhaGw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:59WJ85+/Te/L+ZVmhGsE6XAk29g= sha1:bXNNt1kIOVl7+vUzIGK0hP+uhpk=
Xref: csiph.com comp.lang.c:386302
Malcolm McLean writes:
> On 20/06/2024 16:05, Tim Rentsch wrote:
>
[.. on qsort compare function ..]
>> My reading of the C standard is that the comparison function
>> must impose a total ordering on the elements actually present
>> in the array, or is undefined behavior if it does not. In
>> other words it's okay if the comparison function doesn't
>> define a proper order relation, as long as there are no
>> inconsistencies between values that actually occur in the
>> particular array being sorted.
>
> Yes, a qsort written in the natural way can getstuck if a
> sub0array it considered sorted becmes not sortted on the next
> pass.
Not get stuck. The array might not be sorted correctly,
but the algorithm doesn't get stuck.