Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: sorting Was: Isn't that beauty ? (no it's not)
Date: Mon, 06 Apr 2026 13:48:04 -0700
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <868qazzugr.fsf@linuxsc.com>
References: <10otm7r$1ntrg$1@raubtier-asyl.eternal-september.org> <10p30kr$13nd$2@raubtier-asyl.eternal-september.org> <10p3jgn$80c7$1@dont-email.me> <10p9q0h$2a77o$1@dont-email.me> <10pa02q$2d5us$1@dont-email.me> <10pa4eg$2dtli$5@dont-email.me> <10pa78l$2fjaa$1@dont-email.me> <10palrv$2jpeu$2@dont-email.me> <10pbf0q$2rtq3$1@dont-email.me> <10pbg8f$2spms$2@dont-email.me> <10pbhud$2tbk0$2@dont-email.me> <10pcvr2$3ednq$2@dont-email.me> <20260318112151.000021dc@yahoo.com> <10pdu8k$3o60c$1@dont-email.me> <20260319111959.0000447c@yahoo.com> <10ph2db$pn58$1@dont-email.me> <20260319172955.000062ce@yahoo.com> <10phfh8$u3oe$1@dont-email.me> <20260319214046.000004b5@yahoo.com> <10pi29u$15114$1@dont-email.me> <20260320140110.00006b84@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 06 Apr 2026 20:48:05 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9fa7580ab63f06b181c1510d363a99a"; logging-data="2499914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+002gkI2FjM0NyJVLXlimhV0Cv0APQR30="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Fc8aJcSKK/xyUeDXes6dlgm/mlw= sha1:+G7TBGMKa0xuStljPk4w/uMmcdQ=
Xref: csiph.com comp.lang.c:397391
Michael S writes:
[discussion of sorting code]
>> -----------------------
>> void isort(char** data, int ll, int rr) {
>> char* temp;
>> int i = ll, j = rr;
>> char* pivot = data[(ll + rr) / 2];
>>
>> do {
>> while (strcmp(pivot, data[i]) > 0 && i < rr) ++i;
>> while (strcmp(pivot, data[j]) < 0 && j > ll) --j;
>>
>> if (i <= j) {
>> temp = data[i]; data[i] = data[j]; data[j] = temp;
>> ++i;
>> --j;
>> }
>> } while (i <= j);
>>
>> if (ll < j) isort(data, ll, j);
>> if (i < rr) isort(data, i, rr);
>> }
>>
>> //For a char* array A of N elements, call as 'isort(A, 0, n-1)'.
>
> Looks o.k. speed wise.
> It is not ideomatic C,
What about the code prompts you to say it is not idiomatic C?
Is it because there is a line with multiple statements on it,
or is there something else?
Personally I would not call this code non-idiomatic, with
having three statements on one line a minor style exception.
Also I think Bart should be applauded for posting code that
AFAICT falls completely within the confines of ISO C, and
even looks fairly natural, style-wise.