• Small challenge: sort names

    From DFS@3:633/10 to All on Tue Apr 7 23:14:41 2026
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast,
    James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson,
    Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.















































































    ------------------------------------------------------------------
    No peeking!
    ------------------------------------------------------------------
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    char names[2000] = {"Martin Hohenberg, Jae Yang, Tim Bando, Daniel
    Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit,
    Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher
    Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane
    Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012,
    John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova"};


    //count characters in a string
    int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return cnt;}

    //compare for qsort
    int comparechar( const void *a, const void *b)
    {
    const char **chara = (const char **)a;
    const char **charb = (const char **)b;
    return strcasecmp(*chara, *charb);
    //return strcmp(*chara, *charb);
    }


    //left trim spaces
    void ltrim(char *str)
    {
    int totrim = strspn(str," ");
    if (totrim > 0)
    {
    int len = strlen(str);
    if (totrim == len)
    { str[0] = '\0'; }
    else
    {memmove(str, str + totrim, len + 1 - totrim);}
    }
    }


    int main(void)
    {

    //vars
    char delim[2] = ",";
    int i=0,j=0;

    //number of names is commas + 1
    int namecnt = countchr(names,',') + 1;

    //name array: one column for first-last, one for last-first
    char *narr[2][namecnt];

    char *flname, lfname[30]; // full names
    char *fname, *lname; // part names
    char tmp[30]="";

    // parse full names from string
    // then parse first and last from full name
    // add both into array
    char *dup = strdup(names);
    while((flname = strsep(&dup,delim)) != NULL )
    {
    ltrim(flname);
    if(countchr(flname,' ')>0)
    {
    lname = strrchr(flname,' ')+1;
    memset(tmp, '\0', sizeof(tmp));
    strncat(tmp,flname,strlen(flname)-strlen(lname)-1);
    fname = strdup(tmp);
    }
    else
    {
    lname = strdup(flname);
    fname = strdup("");
    fname[strlen(fname)-2] = '\0';
    }

    sprintf(lfname,"%s %s",lname,fname);
    narr[0][i]= strdup(flname);
    narr[1][i]= strdup(lfname);
    i++;
    }


    //add list of last-first names into array then sort it
    char *sarr[namecnt];
    for(i=0;i<namecnt;i++) {sarr[i] = narr[1][i];}
    qsort(sarr, namecnt, sizeof(char*), comparechar);

    //print first-last in order by last-first
    for(i=0;i<namecnt;i++)
    {
    for(j=0;j<namecnt;j++)
    {
    if(narr[1][j] == sarr[i])
    {
    printf("%d %s\n",i+1, narr[0][j]);
    break;
    }
    }
    }

    return 0;
    }
    ------------------------------------------------------------------
    71 SLOC


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wed Apr 8 10:22:14 2026
    On 2026-04-08 05:14, DFS wrote:
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last [name] (as shown above) but ordered by last first.

    In cases like this where data with Latin and Greek characters are
    mixed you should clarify or even define how the comparison function
    shall operate on mixed data to create a "correct" ordering.

    Hereabouts we usually insert the "???? ??å??" (starting with the
    letter Delta) before or after the letter 'D'; i.e. using an implicit transcription. But this may not suit other cases. Or artificial ones
    like this challenge, so you should probably clarify for folks who
    are interested to re-implement (or use) a sorting function in "C"
    (with or without a locale setting to do the dirty work).

    ------------------------------------------------------------------
    No peeking!
    [...removed without peeking...]
    71 SLOC
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)

    Honestly; mind to explain what the point of this "C" challenge is?

    (From the application user's perspective the most interesting thing
    would be a sophisticated handling of "mixed locales", but I assume
    you're just using what C's 'str*cmp' functions technically provide
    with whatever environment setting, and the challenge is something
    else?)

    Janis


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Wed Apr 8 12:25:17 2026
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:
    On 2026-04-08 05:14, DFS wrote:
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George
    Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten,
    Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang,
    Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens
    Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang,
    Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse,
    taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon,
    Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip
    Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser, Hal
    Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William
    Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova


    Print first last [name] (as shown above) but ordered by last first.

    In cases like this where data with Latin and Greek characters are
    mixed you should clarify or even define how the comparison function
    shall operate on mixed data to create a "correct" ordering.

    Hereabouts we usually insert the "???? ??å??" (starting with the
    letter Delta) before or after the letter 'D'; i.e. using an implicit transcription. But this may not suit other cases. Or artificial ones
    like this challenge, so you should probably clarify for folks who
    are interested to re-implement (or use) a sorting function in "C"
    (with or without a locale setting to do the dirty work).

    ------------------------------------------------------------------
    No peeking!
    [...removed without peeking...]
    71 SLOC
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)


    Bulky C is more fun!

    "one-liner"? With multiple pipes and tr and sed and awk, maybe.



    Honestly; mind to explain what the point of this "C" challenge is?

    Sure thing: "Print first last (as shown above) but ordered by last first."

    (From the application user's perspective the most interesting thing
    would be a sophisticated handling of "mixed locales", but I assume
    you're just using what C's 'str*cmp' functions technically provide
    with whatever environment setting, and the challenge is something
    else?)

    Just looking to see how a variety of excellent C programmers would
    approach a string/split/sort challenge.


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Wed Apr 8 18:57:46 2026
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:
    On 2026-04-08 05:14, DFS wrote:
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle
    Burkholder, Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams,
    George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave
    Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher
    Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant,
    Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu
    Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse,
    taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan
    Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale
    Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey
    Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark
    Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius
    Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas, Bill Soistman,
    ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous,
    Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last [name] (as shown above) but ordered by last first.

    In cases like this where data with Latin and Greek characters are
    mixed you should clarify or even define how the comparison function
    shall operate on mixed data to create a "correct" ordering.

    Hereabouts we usually insert the "???? ??å??" (starting with the
    letter Delta) before or after the letter 'D'; i.e. using an implicit
    transcription. But this may not suit other cases. Or artificial ones
    like this challenge, so you should probably clarify for folks who
    are interested to re-implement (or use) a sorting function in "C"
    (with or without a locale setting to do the dirty work).

    ------------------------------------------------------------------
    No peeking!
    [...removed without peeking...]
    71 SLOC
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)


    Bulky C is more fun!

    "one-liner"?ÿ With multiple pipes and tr and sed and awk, maybe.



    Honestly; mind to explain what the point of this "C" challenge is?

    Sure thing: "Print first last (as shown above) but ordered by last first."

    (From the application user's perspective the most interesting thing
    would be a sophisticated handling of "mixed locales", but I assume
    you're just using what C's 'str*cmp' functions technically provide
    with whatever environment setting, and the challenge is something
    else?)

    Just looking to see how a variety of excellent C programmers would
    approach a string/split/sort challenge.


    These are more higher level tasks than you'd want to use C for. And
    everyone's going to do it a slightly different way.

    You also seem to value LoC as a metric. Your version was labeled as 71
    SLOC, I assume including this function:

    //count characters in a string
    int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a string
    (like the comment says)? But strlen will do that. Then I noticed that
    the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it returned 1,
    not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Now it's clearer! It's counting occurrences of 'chr' within 'str'.

    This adds 6 SLOC, but IMO it's worth it. Striving to get the smallest
    LOC meant poorer quality code, not helped by the misleading comment, or
    the choice of 'c' as the index.

    I'd write it like this:

    int countchr(char *s, char ch) {
    int n = 0;
    while (*s) {
    if (*s == ch) n++;
    ++s;
    }
    return n;
    }

    Then if worried about line-count, I might try:

    int countchr(char *s, char ch) {
    int n = 0;
    while (*s) n += (*s++ == ch);
    return n;
    }

    This is actually 12 characters shorter when your version, even with space-based indents (normally I use hard tabs) and extra white space.



    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Wed Apr 8 21:04:56 2026
    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a string >(like the comment says)? But strlen will do that. Then I noticed that
    the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it returned 1,
    not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }




    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Thu Apr 9 00:10:30 2026
    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int
    c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a
    string (like the comment says)? But strlen will do that. Then I
    noticed that the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it
    returned 1, not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }




    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }





    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Wed Apr 8 17:13:17 2026
    On 4/8/2026 1:57 PM, Bart wrote:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:
    On 2026-04-08 05:14, DFS wrote:
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle
    Burkholder, Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams,
    George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave
    Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher
    Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant,
    Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu
    Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken
    LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan
    Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale
    Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey
    Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark
    Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius
    Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas, Bill Soistman,
    ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous,
    Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last [name] (as shown above) but ordered by last first.

    In cases like this where data with Latin and Greek characters are
    mixed you should clarify or even define how the comparison function
    shall operate on mixed data to create a "correct" ordering.

    Hereabouts we usually insert the "???? ??å??" (starting with the
    letter Delta) before or after the letter 'D'; i.e. using an implicit
    transcription. But this may not suit other cases. Or artificial ones
    like this challenge, so you should probably clarify for folks who
    are interested to re-implement (or use) a sorting function in "C"
    (with or without a locale setting to do the dirty work).

    ------------------------------------------------------------------
    No peeking!
    [...removed without peeking...]
    71 SLOC
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)


    Bulky C is more fun!

    "one-liner"?ÿ With multiple pipes and tr and sed and awk, maybe.



    Honestly; mind to explain what the point of this "C" challenge is?

    Sure thing: "Print first last (as shown above) but ordered by last
    first."

    (From the application user's perspective the most interesting thing
    would be a sophisticated handling of "mixed locales", but I assume
    you're just using what C's 'str*cmp' functions technically provide
    with whatever environment setting, and the challenge is something
    else?)

    Just looking to see how a variety of excellent C programmers would
    approach a string/split/sort challenge.


    These are more higher level tasks than you'd want to use C for.

    ? string.h exists for a reason.


    And everyone's going to do it a slightly different way.

    That's what I'm hoping.


    You also seem to value LoC as a metric. Your version was labeled as 71
    SLOC, I assume including this function:

    //count characters in a string
    int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return cnt;}

    I couldn't quite figure out what it did; counting characters in a string (like the comment says)? But strlen will do that. Then I noticed that
    the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it returned 1,
    not 4 or 5.

    So I refactored it like this:

    ÿ int countchr(char *str, char chr) {
    ÿÿÿÿÿ int c=0, cnt=0;
    ÿÿÿÿÿ while (str[c]!='\0') {
    ÿÿÿÿÿÿÿÿÿ if (str[c] == chr) cnt++;
    ÿÿÿÿÿÿÿÿÿ c++;
    ÿÿÿÿÿ }
    ÿÿÿÿÿ return cnt;
    ÿÿ }

    Now it's clearer! It's counting occurrences of 'chr' within 'str'.

    Yep. My description was bad.


    This adds 6 SLOC, but IMO it's worth it. Striving to get the smallest
    LOC meant poorer quality code, not helped by the misleading comment, or
    the choice of 'c' as the index.

    I'd write it like this:

    ÿ int countchr(char *s, char ch) {
    ÿÿÿÿÿ int n = 0;
    ÿÿÿÿÿ while (*s) {
    ÿÿÿÿÿÿÿÿÿ if (*s == ch) n++;
    ÿÿÿÿÿÿÿÿÿ ++s;
    ÿÿÿÿÿ }
    ÿÿÿÿÿ return n;
    ÿ }

    Then if worried about line-count, I might try:

    ÿ int countchr(char *s, char ch) {
    ÿÿÿÿÿ int n = 0;
    ÿÿÿÿÿ while (*s) n += (*s++ == ch);
    ÿÿÿÿÿ return n;
    ÿ }

    This is actually 12 characters shorter when your version, even with space-based indents (normally I use hard tabs) and extra white space.

    Cool improvements.

    But no code for the challenge? I know it looks lame at first, but it's actually kind of painful to figure out.

    And I notice I didn't specify the output format. I want it to look like
    this:

    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mordant
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping


    If you have any high-level or low-level challenges, post them. Seeing
    other approaches, discussing them, refining my code... it's my favorite
    way to use/learn C.

    The CSES Problem Sets and Project Euler are good, too, but they're more
    lonely endeavors.

    Thanks for the feedback.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Wed Apr 8 23:35:35 2026
    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int
    c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a
    string (like the comment says)? But strlen will do that. Then I
    noticed that the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it
    returned 1, not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }




    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Thu Apr 9 02:59:01 2026
    On Wed, 08 Apr 2026 23:35:35 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int
    c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a
    string (like the comment says)? But strlen will do that. Then I
    noticed that the extra 'chr' parameter, so maybe it stops at
    'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it
    returned 1, not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }




    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.


    Which is irrelevant in this specific case.
    BTW, I think that (ptr != 0) is guaranteed to work even on systems with
    null pointers not being numerically zero. But I am not certain about it.
    What I am certain is that on the right side of assignment to pointer 0
    always acts the same as NULL.
    But that's too irrelevant for our case.

    As to being pedantic w.r.t. '\0', may be you acquired this habit
    because of C++? If I am not mistaken, in C++ '\0' has type char and due
    to that (or because of, which is IMHO, more appropriate wording) can in
    some contexts lead to results different from 0, with differences as huge
    as call to completely different procedure. It does not happen in C where
    we have no misfeature of type based static polymorphism.



    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Apr 8 17:27:37 2026
    scott@slp53.sl.home (Scott Lurndal) writes:
    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int
    c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a
    string (like the comment says)? But strlen will do that. Then I
    noticed that the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it
    returned 1, not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }

    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    I wouldn't, but it's a matter of taste.

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    I'd probably use 0 rather than 0u for an initial value of a size_t
    object. 0u is probably going to have to be converted anyway (unless
    size_t happens to be unsigned int). I don't mind relying on the
    implicit conversion in `size_t count = 0;`.

    But for `*str != 0`, I prefer `*str != '\0'` -- not because it
    matters to the compiler (it doesn't), but because I find it easier
    to read. I like the visible reminder that it's a character value.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    It does. A constant 0 is always a null pointer constant.
    Converting an NPC to a pointer type, implicitly or explicitly,
    always yields a null pointer value, regardless of how null pointer
    values happen to be represented. But I still prefer using NULL
    (or nullptr in C23 or C++) when I want a null pointer value.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Apr 8 18:46:00 2026
    DFS <nospam@dfs.com> writes:

    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George
    Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten,
    Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang,
    Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens
    Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang,
    Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse,
    taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon,
    Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip
    Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser, Hal
    Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ?????, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.

    My solution breaks down as follows

    3 three #include lines
    4 four blank lines between functions (or #include)
    12 four functions, each with three non-body lines
    10 one function (main) with 10 lines in its body
    2 one function with 2 lines in its body
    2 two functions with 1 body line each
    ----
    33 total lines


    Style observed

    Lines at most 79 characters
    Only one statement or declaration per line, except after for() or if()
    a single-statement body is allowed on same line, if everything fits
    Exactly one blank line before each function
    Indented nested blocks (eg, after for()) always use braces, 1TBS
    No blank lines inside functions
    All functions other than main() defined before use (the opposite
    of my preferred style)

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Apr 8 22:14:25 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    Michael S <already5chosen@yahoo.com> writes:

    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:

    On 08/04/2026 17:25, DFS wrote:

    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int
    c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a
    string (like the comment says)? But strlen will do that. Then I
    noticed that the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it
    returned 1, not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }

    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation.

    A dangerous habit if followed out of habit. For example:

    size_t ones = -1; // makes 'ones' be all one bits
    size_t ones = -1u; // oops! can be 32 ones rather than 64

    I always explicitly check against NULL rather than using !ptr,
    for example.

    I consider the treatment of null pointers and the way if(), for(),
    while(), etc, work to be a pleasing symmetry and an elegant
    simplifying principle of the C language. Pointers are a special
    kind of multi-valued booleans. Writing this

    char *p = ...;
    if( p != NULL ) ...

    is just as repugnant as this

    _Bool b = ...;
    if( b != false ) ...

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Apr 9 02:19:22 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]
    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    Any C implementation where !ptr does the wrong thing almost certainly
    does not exist. It's difficult to imagine that a C compiler with
    such a fundamental bug would ever go out the door.

    It's barely possible that compiler that uses a representation other
    than all-bits-zero for null pointers might have such a bug, but
    (a) anyone creating such an implementation will almost certainly
    be extremely careful to get such things right, and (b) I'm not sure
    that any such compilers even exist, except perhaps for old systems
    that would be considered exotic today.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Thu Apr 9 06:29:19 2026
    On 2026-04-08 19:59, Michael S wrote:
    ...
    BTW, I think that (ptr != 0) is guaranteed to work even on systems with
    null pointers not being numerically zero. But I am not certain about it.
    What I am certain is that on the right side of assignment to pointer 0
    always acts the same as NULL.

    An integer constant expression with a value of 0 is a null pointer
    constant. As such, when it appears in certain contexts (comparison with
    a pointer type being one of them) it is implicitly converted to the
    appropriate pointer type. When any null pointer constant is converted to pointer type, the result is guaranteed to be a null pointer. All null
    pointers compare equal to each other, and unequal to any pointer to an
    actual object or function.
    Note, in particular, that this applies even in cases such as
    if(condition) where the condition is implicitly compared for equality
    with 0.

    These rules do NOT apply to non-constant expressions with integer type
    and a value of 0. Of course, on many systems, those are in fact treated
    the same as null pointer constants, which often leads people to write
    code assuming incorrectly that they are required to be treated the same.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Thu Apr 9 15:06:50 2026
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]
    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    Any C implementation where !ptr does the wrong thing almost certainly
    does not exist. It's difficult to imagine that a C compiler with
    such a fundamental bug would ever go out the door.

    It's barely possible that compiler that uses a representation other
    than all-bits-zero for null pointers might have such a bug, but
    (a) anyone creating such an implementation will almost certainly
    be extremely careful to get such things right, and (b) I'm not sure
    that any such compilers even exist, except perhaps for old systems
    that would be considered exotic today.

    Or even obsolete. The systems in question were all retired by
    2010, and never had a C compiler. The system was BCD and the
    six digit 'undigit' value of EEEEEE was chosen as the NIL (NULL)
    pointer value.


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Thu Apr 9 15:15:49 2026
    In article <20260409025901.00002bc6@yahoo.com>,
    Michael S <already5chosen@yahoo.com> wrote:
    On Wed, 08 Apr 2026 23:35:35 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    [snip]

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }




    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    Which is irrelevant in this specific case.
    BTW, I think that (ptr != 0) is guaranteed to work even on systems with
    null pointers not being numerically zero. But I am not certain about it.
    What I am certain is that on the right side of assignment to pointer 0
    always acts the same as NULL.
    But that's too irrelevant for our case.

    It's easy enough to verify looking at a canonical source.
    Section 6.3.2.3 coupled with 6.5.9 of C18 suggest this is
    guaranteed to work.

    As to being pedantic w.r.t. '\0', may be you acquired this habit
    because of C++? If I am not mistaken, in C++ '\0' has type char and due
    to that (or because of, which is IMHO, more appropriate wording) can in
    some contexts lead to results different from 0, with differences as huge
    as call to completely different procedure. It does not happen in C where
    we have no misfeature of type based static polymorphism.

    '\0' is indeed a `char` in C++. But I don't think that really
    changes the point, which is more about semantics. Why NOT use a
    relevant character constant instead of `0`? It's not whether
    one can or not, or whether it's semantically equivalent, or
    whether C's `char` type is really an integer in a trenchcoat:
    it's using the appropriate constant to match the domain: in this
    case, matching character data.

    - Dan C.


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sat Apr 11 08:31:11 2026
    On 2026-04-08 18:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)

    Bulky C is more fun!

    Well, opinions differ. I indeed like little obfuscated challenges.
    But for production code (whether professional or personal) clear
    code is preferable.


    "one-liner"?ÿ With multiple pipes and tr and sed and awk, maybe.

    It depends. If the entries are in one line each it's just 'sort'.

    If you have them all in a one line I'd usually use simply a 'sed'
    to create lines, and if the output shall be in lines again, then
    another 'sed'. That's all. (Less that 60 characters for all.)


    Honestly; mind to explain what the point of this "C" challenge is?

    Sure thing: "Print first last (as shown above) but ordered by last first."

    That doesn't explain the point of such primitive "challenges".
    (But never mind.)

    As noted with a previous "challenge" I see neither a challenge
    for the "C" language, nor an algorithmic challenge here. (YMMV.)

    Janis

    [...]


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sat Apr 11 08:44:00 2026
    On 2026-04-08 23:04, Scott Lurndal wrote:
    Bart <bc@freeuk.com> writes:
    On 08/04/2026 17:25, DFS wrote:
    On 4/8/2026 4:22 AM, Janis Papanagnou wrote:

    //count characters in a string
    int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    I couldn't quite figure out what it did; counting characters in a string
    (like the comment says)? But strlen will do that. Then I noticed that
    the extra 'chr' parameter, so maybe it stops at 'chr'.

    But when I tried running it as countchr("ABCDEFGH", 'E'), it returned 1,
    not 4 or 5.

    So I refactored it like this:

    int countchr(char *str, char chr) {
    int c=0, cnt=0;
    while (str[c]!='\0') {
    if (str[c] == chr) cnt++;
    c++;
    }
    return cnt;
    }

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }

    I'd usually see whether the initialization could also be placed in
    the loop; I dislike those "incomplete" "C" loops. Or I'd have used
    a 'while' loop which I consider to be clearer

    while (*str != '\0')
    count += (*str++ == match);

    I'd probably even omitted the comparison and relied on the implicit
    non-0 (*str) test. (I don't recall that this is a problem, or is it?)

    That's at least what I'd call even a bit more idiomatic, reducing the expressions to that extent.

    Janis


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sat Apr 11 08:59:31 2026
    On 2026-04-08 23:13, DFS wrote:
    [...]

    And I notice I didn't specify the output format.ÿ I want it to look like this:

    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mordant
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping

    Since you asked in another post; then it would be (with Unix tools on
    the command-line) just a single 'sed' to make the data line-canonical
    for the sort-processing

    sed 's/, /\n/g' | sort -k2 -k1

    (so just 30 characters, compared to the 60 with a re-lining-up 'sed').

    Janis

    [...]


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sat Apr 11 09:34:26 2026
    On 2026-04-11 08:59, Janis Papanagnou wrote:
    On 2026-04-08 23:13, DFS wrote:
    [...]

    And I notice I didn't specify the output format.ÿ I want it to look
    like this:

    BTW; you also didn't specify what to do with words that don't have
    two name components.

    I noticed, besides the already mentioned Greek entry ("???? ??å??") a
    couple single word entries (darrin, Mordant, ReallyBored, taishi28012).
    What to do with those?

    Mind that for a sensible data processing you'd fix input data before
    doing the processing. (Otherwise you'd get trash-in trash-out quality,
    and/or bulky/unmaintainable programs to "fix" data issues on the fly.)

    Janis

    [...]


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Sat Apr 11 08:49:11 2026
    cross@spitfire.i.gajendra.net (Dan Cross) writes:

    In article <20260409025901.00002bc6@yahoo.com>,
    Michael S <already5chosen@yahoo.com> wrote:

    On Wed, 08 Apr 2026 23:35:35 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    [snip]

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }

    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    Which is irrelevant in this specific case.
    BTW, I think that (ptr != 0) is guaranteed to work even on systems
    with null pointers not being numerically zero. But I am not
    certain about it. What I am certain is that on the right side of
    assignment to pointer 0 always acts the same as NULL.
    But that's too irrelevant for our case.

    It's easy enough to verify looking at a canonical source.
    Section 6.3.2.3 coupled with 6.5.9 of C18 suggest this is
    guaranteed to work.

    As to being pedantic w.r.t. '\0', may be you acquired this habit
    because of C++? If I am not mistaken, in C++ '\0' has type char
    and due to that (or because of, which is IMHO, more appropriate
    wording) can in some contexts lead to results different from 0,
    with differences as huge as call to completely different procedure.
    It does not happen in C where we have no misfeature of type based
    static polymorphism.

    '\0' is indeed a `char` in C++. But I don't think that really
    changes the point, which is more about semantics. Why NOT use a
    relevant character constant instead of `0`? It's not whether
    one can or not, or whether it's semantically equivalent, or
    whether C's `char` type is really an integer in a trenchcoat:
    it's using the appropriate constant to match the domain: in this
    case, matching character data.

    There's no reason to use a constant at all; just write '*str'.
    This writing isn't just idiomatic -- it's integral to how the
    language was designed, not only for string termination but also
    the rules for null pointers and how expressions work in the
    context of for(), if(), and while(). Writing != 0 or != '\0' is
    a holdover from being used to writing Pascal (or any number of
    other earlier languages). When in Rome, do as the Romans do.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Sat Apr 11 19:59:39 2026
    In article <86eckla45k.fsf@linuxsc.com>,
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:

    In article <20260409025901.00002bc6@yahoo.com>,
    Michael S <already5chosen@yahoo.com> wrote:

    On Wed, 08 Apr 2026 23:35:35 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Wed, 08 Apr 2026 21:04:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    [snip]

    Idiomatically, I might have written

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0u;
    for(; *str != '\0'; str++) count += (*str == match);
    return count;
    }

    I'd change it to

    size_t
    countchar(const char *str, char match)
    {
    size_t count = 0;
    for(; *str != 0; str++) count += (*str == match);
    return count;
    }

    Personally, I prefer to properly identify integer constants
    with the appropriate type annotation. I always explicitly
    check against NULL rather than using !ptr, for example. I
    never use an unadorned integer for a character constant,
    rather using either 'c' for printables, the legal escapes
    (e.g. \n) and for any non-printable, the appropriate
    octal escape.

    Perhaps some of this is pedantic. I worked with a system
    where the null pointer constant was not the value zero, so
    I'm aware that !ptr may not actually do the right thing in
    such cases.

    Which is irrelevant in this specific case.
    BTW, I think that (ptr != 0) is guaranteed to work even on systems
    with null pointers not being numerically zero. But I am not
    certain about it. What I am certain is that on the right side of
    assignment to pointer 0 always acts the same as NULL.
    But that's too irrelevant for our case.

    It's easy enough to verify looking at a canonical source.
    Section 6.3.2.3 coupled with 6.5.9 of C18 suggest this is
    guaranteed to work.

    As to being pedantic w.r.t. '\0', may be you acquired this habit
    because of C++? If I am not mistaken, in C++ '\0' has type char
    and due to that (or because of, which is IMHO, more appropriate
    wording) can in some contexts lead to results different from 0,
    with differences as huge as call to completely different procedure.
    It does not happen in C where we have no misfeature of type based
    static polymorphism.

    '\0' is indeed a `char` in C++. But I don't think that really
    changes the point, which is more about semantics. Why NOT use a
    relevant character constant instead of `0`? It's not whether
    one can or not, or whether it's semantically equivalent, or
    whether C's `char` type is really an integer in a trenchcoat:
    it's using the appropriate constant to match the domain: in this
    case, matching character data.

    There's no reason to use a constant at all; just write '*str'.
    This writing isn't just idiomatic -- it's integral to how the
    language was designed, not only for string termination but also
    the rules for null pointers and how expressions work in the
    context of for(), if(), and while(). Writing != 0 or != '\0' is
    a holdover from being used to writing Pascal (or any number of
    other earlier languages).

    This is subjective, and _a_ response from a different school of
    thought may be that `*str` is not a boolean type, and thus
    should not be used in a boolean context. You may disagree; I
    may occasionally disagree myself, but again, it's subjective.

    When in Rome, do as the Romans do.

    This is the critical part. Many Unix and Unix-like kernels, for
    instance, have style guides that demand comparison against an
    appropriately type constants, along with other style rules about
    the placement of braces, use of whitespace, indentation, and so
    on. If one works in those kernels, one doesn't really have a
    lot of choice: one must do what the Romans in that instance of
    Rome do, regardless of personal preference.

    - Dan C.


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Sun Apr 12 06:35:01 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]

    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    Any C implementation where !ptr does the wrong thing almost certainly
    does not exist. It's difficult to imagine that a C compiler with
    such a fundamental bug would ever go out the door.

    It's barely possible that compiler that uses a representation other
    than all-bits-zero for null pointers might have such a bug, but
    (a) anyone creating such an implementation will almost certainly
    be extremely careful to get such things right, and (b) I'm not sure
    that any such compilers even exist, except perhaps for old systems
    that would be considered exotic today.

    Or even obsolete. The systems in question were all retired by
    2010, and never had a C compiler. The system was BCD and the
    six digit 'undigit' value of EEEEEE was chosen as the NIL (NULL)
    pointer value.

    It would be nice if in the future it were stated directly when a
    non-C environment is the context of a comment. I mistakenly
    understood that what you were saying had to do with experience
    using some unusual C compiler.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Sun Apr 12 06:48:19 2026
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]

    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    Any C implementation where !ptr does the wrong thing almost certainly
    does not exist. It's difficult to imagine that a C compiler with
    such a fundamental bug would ever go out the door.

    My usual preference is to draw conclusions based on evidence rather
    imagination or supposition.

    It's barely possible that compiler that uses a representation other
    than all-bits-zero for null pointers might have such a bug, but
    (a) anyone creating such an implementation will almost certainly
    be extremely careful to get such things right, and (b) I'm not sure
    that any such compilers even exist, except perhaps for old systems
    that would be considered exotic today.

    Here again this sounds like just supposition. How much experience
    do you have, and how extensive, using non-mainstream C compilers?
    For myself I can't say I much at all, but I have seen one where
    believe it or not assert() was implemented wrongly. assert()! I
    certainly wouldn't have guessed that before actually seeing it.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Sun Apr 12 14:51:46 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    scott@slp53.sl.home (Scott Lurndal) writes:


    Or even obsolete. The systems in question were all retired by
    2010, and never had a C compiler. The system was BCD and the
    six digit 'undigit' value of EEEEEE was chosen as the NIL (NULL)
    pointer value.

    It would be nice if in the future it were stated directly when a
    non-C environment is the context of a comment. I mistakenly
    understood that what you were saying had to do with experience
    using some unusual C compiler.

    I was in the OS group at the time. The languages group had
    started looking at writing a C compiler for the architecture, but
    it never panned out (and there was little interest from the
    predominantly COBOL customer base).

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From BGB@3:633/10 to All on Sun Apr 12 13:08:41 2026
    On 4/8/2026 3:22 AM, Janis Papanagnou wrote:
    On 2026-04-08 05:14, DFS wrote:
    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George
    Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten,
    Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang,
    Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens
    Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang,
    Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse,
    taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon,
    Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip
    Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser, Hal
    Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William
    Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova


    Print first last [name] (as shown above) but ordered by last first.

    In cases like this where data with Latin and Greek characters are
    mixed you should clarify or even define how the comparison function
    shall operate on mixed data to create a "correct" ordering.

    Hereabouts we usually insert the "???? ??å??" (starting with the
    letter Delta) before or after the letter 'D'; i.e. using an implicit transcription. But this may not suit other cases. Or artificial ones
    like this challenge, so you should probably clarify for folks who
    are interested to re-implement (or use) a sorting function in "C"
    (with or without a locale setting to do the dirty work).


    FWIW...


    One approach I had defined for some filesystem code of mine:
    Normalize encoding as UTF-8 or similar;
    Do a byte-for-byte comparison of the UTF-8 strings.

    UTF-8 normalization can itself get complicated.
    Though, keeping the set of rules minimal can help;
    Otherwise, the task can become unreasonable.


    Otherwise, the normalization and collation rules were assumed to be independent of locale.

    Well, and tend not to be collation-correct even for US ASCII (where,
    say, people often expect alphabetic ordering and letters to come first,
    unlike ASCII ordering where numbers come first, then upper case, then
    lower case, with various symbols between them, ...).



    For storage, there were a few options:
    Option 1:
    Leave everything as UTF-8, using only UTF-8;
    Option 2:
    Allow CP1252 if name string could be represented exactly;
    And, the 1252 would not be confused for valid UTF-8.


    The merit of 2 is that, besides purely ASCII filenames, CP1252 names
    were a solid second place in my states, followed in the 3rd place by
    names with emojis, and 4th place by Chinese characters and similar, ...

    Granted, person names are different from filenames so would likely have
    a different ranking (well, and you can hope people don't start naming
    kids with names containing emojis, ...).

    Though, can note that the reasoning in this case was that there was a short-name case (names that fit under a 48-byte limit), and long-name
    case (names that exceeded 48 bytes), and the difference between 1252 and
    UTF-8 could often be "make or break" for a name fitting within the 48
    byte limit (without the complexity of full code-page handling).

    Though, in this case, if 1252 was used, one could end up with it doing byte-for-byte comparison between UTF-8 and 1252, but this was OK (well,
    and for purposes of sorting, it only cared about the short-name field,
    which for long names would contain the first 40 bytes with the last 8
    bytes replaced with a hash of the full length name).


    In this case, name hash algorithm was defined as, roughly:
    uint64_t DfsLongNameHash(char *name)
    {
    uint64_t h0, h1, h;
    char *s;
    int i, c, l, n;

    l=strlen(name);
    s=name; h0=1; h1=0;
    n=l>>2;
    for(i=0; i<n; i++)
    { h1+=h0; h0+=*(uint32_t *)s; s+=4; }
    if(n&3)
    {
    c=*(uint32_t *)s;
    c&=((1U<<((n&3)*8))-1);
    h1+=h0; h0+=c;
    }
    h0=((uint32_t)h0)+(h0>>32); h1=((uint32_t)h1)+(h1>>32);
    h0=((uint32_t)h0)+(h0>>32); h1=((uint32_t)h1)+(h1>>32);
    h=h0|(h1<<32);
    return(h);
    }

    ...


    Hasn't seen that much practical use thus far.
    Initially it was motivated by:
    FAT is kinda limited,
    and faking a Unix-style FS on top of FAT is lame.
    NTFS was way too needlessly complicated.
    EXT2 almost works, but:
    Has some needless design cruft that was better handled in NTFS;
    General approach makes sense though.
    Handling of directories would be needlessly inefficient.
    Linear search over variable-sized dirents.


    So, ended up with a design partway between NTFS and EXT2, but aiming to
    avoid needless complexity and to keep the design reasonably efficient.
    Inode table: Hybrid approach,
    inode-table is self-defining like the MFT.
    Block management strategy superficially similar to EXT2.
    Though, using a single global bitmap, rather than block groups;
    Bitmap and inode table can grow as needed, ...
    Directories used fixed-size dirents organized into an AVL tree.
    In this case, was chosen as a compromise.
    Linear directories are simpler, but scale poorly.
    AVL trees were intermediate between linear and B-Trees.
    Efficiency analysis favored AVL trees in this case.

    Though, the pain of rebalancing trees on insert/delete left me
    questioning the choice. Because delete was too much of a pain, ended up
    using a strategy where it would mark nodes as deleted and then (as
    convenient) actually remove the entries in subsequent node rotates (and
    also making the re-balancing more lax as I had noted that +/- 2 would
    result in significantly less rotates than +/- 1).

    As, dealing with directory insert/delete handling became one of the more complicated parts of the filesystem.

    Over the range of typical directory sizes, AVL trees remained as the
    more efficient option, only getting edged out by B-Trees for excessively
    large directories (but nearly always having a cheaper lookup cost vs
    linear search, even if insert/delete costs are often higher).

    ...


    Though, can note that with such an approach, something seemingly minor
    like a change in normalization or collation behavior could break the
    ability of the FS driver to open files. Which is a possible area for
    concern.


    Though, for NTFS, the strategy had been to ship things like the
    code-point collation ordering tables along with the filesystem
    (theoretically, could depend on the locale the FS was formatted under;
    AFAIK in practice a global set of tables was used independent of
    locale). Better IMO to keep collation as part of a UI-presentation thing (whether the file browser presents files ordered in a way that makes
    sense for the user's locale being a locale-specific thing).


    Was simplified slightly by assuming everything is case-sensitive.
    Actually, I went a little non-standard by even having the FAT driver as
    case sensitive.

    ...


    ------------------------------------------------------------------
    No peeking!
    [...removed without peeking...]
    71 SLOC
    No necessity for peeking since I'd write a Unix 'sort' one-liner
    (instead of a bulky "C" program). ;-)

    Honestly; mind to explain what the point of this "C" challenge is?

    (From the application user's perspective the most interesting thing
    would be a sophisticated handling of "mixed locales", but I assume
    you're just using what C's 'str*cmp' functions technically provide
    with whatever environment setting, and the challenge is something
    else?)


    Yeah, mostly agreed here.


    Janis



    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Sun Apr 12 16:15:46 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]

    The semantics of !ptr has been codified to mean 1 for null pointers
    since the original C standard. Heck, even during the 1970s when C
    allowed assigning integers directly to pointers, K&R said that
    assigning 0 to a pointer produces a pointer guaranteed to be
    different than a pointer to any object. Any C implementation where
    !ptr does the wrong thing should be avoided like the plague.

    Any C implementation where !ptr does the wrong thing almost certainly
    does not exist. It's difficult to imagine that a C compiler with
    such a fundamental bug would ever go out the door.

    My usual preference is to draw conclusions based on evidence rather imagination or supposition.

    Good for you.

    It's barely possible that compiler that uses a representation other
    than all-bits-zero for null pointers might have such a bug, but
    (a) anyone creating such an implementation will almost certainly
    be extremely careful to get such things right, and (b) I'm not sure
    that any such compilers even exist, except perhaps for old systems
    that would be considered exotic today.

    Here again this sounds like just supposition. How much experience
    do you have, and how extensive, using non-mainstream C compilers?
    For myself I can't say I much at all, but I have seen one where
    believe it or not assert() was implemented wrongly. assert()! I
    certainly wouldn't have guessed that before actually seeing it.

    Quick summary: You wrote that "Any C implementation where !ptr does
    the wrong thing should be avoided like the plague." My response
    was, to summarize briefly, that such implementations are unlikely
    to exist and not worth worrying about.

    Do you disagree, or are you just criticizing the way I said it?
    I believe I was clear about the basis for my statement. No, I don't
    have a lot of experience with non-mainstream C compilers. I'm not
    going to perform a survey of all historical C implementations.

    Do you have anything useful to say about my point, as opposed to
    how I expressed it?

    I speculate that no released C implementation gets either !ptr or
    2+2 wrong. A bug in the former is, I speculate, more likely than a
    bug in the latter, but neither seems likely. If such a bug exists,
    my guess is that it's in a pre-standard compiler for some system
    that is now obsolete. K&R1 (1978) is less than clear about the
    representation of null pointers.

    Would you be surprised to see a C compiler that handles !ptr
    incorrectly?

    I'd be interested in more information about the implementation
    that implemented assert() incorrectly.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Mon Apr 13 06:31:00 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

    scott@slp53.sl.home (Scott Lurndal) writes:

    Or even obsolete. The systems in question were all retired by
    2010, and never had a C compiler. The system was BCD and the
    six digit 'undigit' value of EEEEEE was chosen as the NIL (NULL)
    pointer value.

    It would be nice if in the future it were stated directly when a
    non-C environment is the context of a comment. I mistakenly
    understood that what you were saying had to do with experience
    using some unusual C compiler.

    I was in the OS group at the time. The languages group had
    started looking at writing a C compiler for the architecture, but
    it never panned out (and there was little interest from the
    predominantly COBOL customer base).

    I'm sure there was a good reason for working in the development
    environment you were using, and I didn't mean to imply otherwise.
    I just wanted a heads-up about the non-C-ness of it.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Apr 16 18:24:58 2026
    As usual - in a superior language.

    #include <iostream>
    #include <utility>
    #include <string_view>
    #include <regex>
    #include <vector>
    #include <algorithm>

    using namespace std;

    static constexpr string_view Names = "Martin Hohenberg, Jae Yang, Tim
    Bando, Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom
    Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long,
    Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L.
    Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil
    Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando,
    John Carmack, Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh
    Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott,
    Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser,
    Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova";

    int main()
    {
    regex
    rxComma( "\\s*([^,]+)(,|$)" ),
    rxRvSurname( "\\s*(\\S+)" ),
    rxGapSpaces( "(\\s+)" );
    match_results<string_view::iterator> mtch;
    match_results<string_view::reverse_iterator> reverseMatch;
    using name = pair<string_view, string_view>;
    vector<name> names;
    for( auto itName = ::Names.begin(); ; itName = mtch[0].second )
    {
    if( !regex_search( itName, ::Names.end(), mtch, rxComma ) )
    break;
    if( !regex_search( reverse_iterator( mtch[1].second ), reverse_iterator( mtch[1].first ), reverseMatch, rxRvSurname ) )
    continue;
    auto
    itSurname = reverseMatch[1].second.base(),
    itSurnameEnd = reverseMatch[1].first.base();
    string_view surname( itSurname, itSurnameEnd );
    auto itForename = mtch[1].first;
    if( !regex_search( reverse_iterator( itSurname ), reverse_iterator(
    itForename ), reverseMatch, rxGapSpaces ) )
    continue;
    auto itForenameEnd = reverseMatch[1].second.base();
    string_view forename( itForename, itForenameEnd );
    names.emplace_back( forename, surname );
    }
    sort( names.begin(), names.end(), []( const name &lhs, const name &rhs ) { return lhs.second < rhs.second; } );
    for( const name &nm : names )
    {
    cout << "\"" << nm.first << "\" - \"" << nm.second << "\"" << endl;
    }
    }

    The cool thing about that that I'm matching a part of the name with
    a reverse-iterator, i.e. I do reverse regex parsing (the regex itself
    is forward).


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Apr 16 18:50:11 2026
    Am 09.04.2026 um 01:59 schrieb Michael S:

    BTW, I think that (ptr != 0) is guaranteed to work even on systems with
    null pointers not being numerically zero. ...

    Sorry, that's ridiculous. Which system ever has used sth. different than
    a physical null-pointer for a logical. And do you really expect that to
    happen in the future ?
    You see uncertainties where ther are non.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Thu Apr 16 18:38:46 2026
    On 16/04/2026 17:24, Bonita Montero wrote:
    As usual - in a superior language.

    #include <iostream>
    #include <utility>
    #include <string_view>
    #include <regex>
    #include <vector>
    #include <algorithm>

    using namespace std;

    static constexpr string_view Names = "Martin Hohenberg, Jae Yang, Tim
    Bando, Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom
    Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L.
    Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil
    Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando,
    John Carmack, Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh
    Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser,
    Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova";

    int main()
    {
    ÿÿÿÿregex
    ÿÿÿÿÿÿÿ rxComma( "\\s*([^,]+)(,|$)" ),
    ÿÿÿÿÿÿÿ rxRvSurname( "\\s*(\\S+)" ),
    ÿÿÿÿÿÿÿ rxGapSpaces( "(\\s+)" );
    ÿÿÿÿmatch_results<string_view::iterator> mtch;
    ÿÿÿÿmatch_results<string_view::reverse_iterator> reverseMatch;
    ÿÿÿÿusing name = pair<string_view, string_view>;
    ÿÿÿÿvector<name> names;
    ÿÿÿÿfor( auto itName = ::Names.begin(); ; itName = mtch[0].second )
    ÿÿÿÿ{
    ÿÿÿÿÿÿÿ if( !regex_search( itName, ::Names.end(), mtch, rxComma ) )
    ÿÿÿÿÿÿÿÿÿÿÿ break;
    ÿÿÿÿÿÿÿ if( !regex_search( reverse_iterator( mtch[1].second ), reverse_iterator( mtch[1].first ), reverseMatch, rxRvSurname ) )
    ÿÿÿÿÿÿÿÿÿÿÿ continue;
    ÿÿÿÿÿÿÿ auto
    ÿÿÿÿÿÿÿÿÿÿÿ itSurname = reverseMatch[1].second.base(),
    ÿÿÿÿÿÿÿÿÿÿÿ itSurnameEnd = reverseMatch[1].first.base();
    ÿÿÿÿÿÿÿ string_view surname( itSurname, itSurnameEnd );
    ÿÿÿÿÿÿÿ auto itForename = mtch[1].first;
    ÿÿÿÿÿÿÿ if( !regex_search( reverse_iterator( itSurname ),
    reverse_iterator( itForename ), reverseMatch, rxGapSpaces ) )
    ÿÿÿÿÿÿÿÿÿÿÿ continue;
    ÿÿÿÿÿÿÿ auto itForenameEnd = reverseMatch[1].second.base();
    ÿÿÿÿÿÿÿ string_view forename( itForename, itForenameEnd );
    ÿÿÿÿÿÿÿ names.emplace_back( forename, surname );
    ÿÿÿÿ}
    ÿÿÿÿsort( names.begin(), names.end(), []( const name &lhs, const name
    &rhs ) { return lhs.second < rhs.second; } );
    ÿÿÿÿfor( const name &nm : names )
    ÿÿÿÿ{
    ÿÿÿÿÿÿÿ cout << "\"" << nm.first << "\" - \"" << nm.second << "\"" <<
    endl;
    ÿÿÿÿ}
    }

    The cool thing about that that I'm matching a part of the name with
    a reverse-iterator, i.e. I do reverse regex parsing (the regex itself
    is forward).


    What's not cool is that it takes 4.7 seconds to compile this 45 line
    program, unoptimised. and 7.7 seconds optimised.

    Does it need to be optimised? I guess so, even if it's just to get the
    size down: optimised is 136KB, unoptimised it's 319KB.

    Tiny C builds the C version in pretty much zero seconds, for a 8KB program.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Apr 16 19:43:47 2026
    Am 16.04.2026 um 19:38 schrieb Bart:

    What's not cool is that it takes 4.7 seconds to compile this 45 line program, unoptimised. and 7.7 seconds optimised.

    Doesn't matter if you need not a third of the time to develop the code.
    And if you like more performance you can use C++20 modules.

    Does it need to be optimised? I guess so, even if it's just to get the
    size down: optimised is 136KB, unoptimised it's 319KB.

    Doesn't matter.

    Tiny C builds the C version in pretty much zero seconds, for a 8KB program.

    Is this really an advantage ? You C guys really suck.
    You continue to see details without noting the overall picture.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Thu Apr 16 19:54:58 2026
    In article <10rr402$1r3mi$1@raubtier-asyl.eternal-september.org>,
    Bonita Montero <Bonita.Montero@gmail.com> wrote:
    Am 09.04.2026 um 01:59 schrieb Michael S:

    BTW, I think that (ptr != 0) is guaranteed to work even on systems with
    null pointers not being numerically zero. ...

    Sorry, that's ridiculous. Which system ever has used sth. different than
    a physical null-pointer for a logical. And do you really expect that to >happen in the future ?
    You see uncertainties where ther are non.

    Hmm, I wonder if the AS/400 has this.

    - Dan C.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Fri Apr 17 16:22:40 2026
    Am 16.04.2026 um 21:54 schrieb Dan Cross:

    In article <10rr402$1r3mi$1@raubtier-asyl.eternal-september.org>,

    Bonita Montero <Bonita.Montero@gmail.com> wrote:

    Sorry, that's ridiculous. Which system ever has used sth. different than
    a physical null-pointer for a logical. And do you really expect that to
    happen in the future ?
    You see uncertainties where ther are non.

    Hmm, I wonder if the AS/400 has this.

    With the AS/400 the NULL-pointer is physically zero. But the AS/400
    has typed registers so that a NULL-pointer is sth. different than a
    register with an zero integer.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Fri Apr 17 20:44:03 2026
    In article <10r537m$in2o$4@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    ...
    Honestly; mind to explain what the point of this "C" challenge is?

    To generate traffic on an otherwise sterile and (almost) dead newsgroup on
    an (almost) dead platform.

    It (and, more generally, its author) has done an admirable job of that.

    Or, to put it another way, what is the point of comp.lang.c?

    Answer that, and you will be most of the way to answering the original question.

    --
    I've been watching cat videos on YouTube. More content and closer to
    the truth than anything on Fox.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Sat Apr 18 11:16:48 2026
    On Tue, 7 Apr 2026 23:14:41 -0400, DFS wrote:

    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, >Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, >James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson, >Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken >Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod >Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ?????, Ron Lauzon, TheFred, Paul >Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.
    ot

    this would be one APL program in "brace" form and its result, because
    here it seems is difficult print 2 chars chars

    s{leftarrow}{apostrophe}Martin Hohenberg, Jae Yang, Tim Bando,
    Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor,
    Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven
    Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz,
    Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack,
    Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken
    LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale
    Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey
    Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark
    Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius
    Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas, Bill Soistman,
    ReallyBored, {\x00CE}{\x2020}{\x00CF}{\x0081}{\x00CE}{\x00B7}
    {\x00CF}{\x201A}
    {\x00CE}{\x201D}{\x00CE}{\x00AC}{\x00CF}{\x0192}{\x00CE} {\x00BF}{\x00CF}{\x201A}, Ron Lauzon, TheFred, Paul Theodoropolous,
    Doug Phillips, Les Vogel, Matt Pollard, Andres
    Cordova{apostrophe}{cr}{lf}

    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}{leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}{leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}

    Mordant
    taishi28012
    darrin
    ReallyBored
    TheFred
    Paul Abbott
    Neil Anuskiewicz
    Tim Bando
    Masa Bando
    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry
    Arnold F. Williams
    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From gggggggggggunit@3:633/10 to All on Sat Apr 18 10:19:41 2026
    $ cat names.txt | tr -d '\n' | sed 's/,/\n/g' | sed 's/^ //g' | awk 'NF ==
    3 { print $1, $3, $2 } NF == 2 { print $1, $2 } NF ==1 { print $1 }' |
    sort -k 2,2 -k 1,1 | awk 'NF == 3 { print $1, $3, $2 } NF == 2 { print
    $1, $2 } NF ==1 { print $1 }'
    darrin
    Mordant
    ReallyBored
    taishi28012
    TheFred
    Paul Abbott
    Neil Anuskiewicz
    Masa Bando
    Tim Bando
    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry
    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    David L. Jessup
    Liudmilla Karukina
    Ken Kennedy
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Arnold F. Williams
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang
    ???? ??å??


    On Tue, 7 Apr 2026 23:14:41 -0400, DFS wrote:

    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.















































































    ------------------------------------------------------------------
    No peeking! ------------------------------------------------------------------
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    char names[2000] = {"Martin Hohenberg, Jae Yang, Tim Bando, Daniel
    Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit,
    Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher
    Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane
    Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012,
    John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres
    Cordova"};


    //count characters in a string int countchr(char *str, char chr)
    {int c=0,cnt=0;while(str[c]!='\0'){if(str[c]==chr){cnt++;}c++;}return
    cnt;}

    //compare for qsort int comparechar( const void *a, const void *b)
    {
    const char **chara = (const char **)a;
    const char **charb = (const char **)b;
    return strcasecmp(*chara, *charb);
    //return strcmp(*chara, *charb);
    }


    //left trim spaces void ltrim(char *str)
    {
    int totrim = strspn(str," ");
    if (totrim > 0)
    {
    int len = strlen(str);
    if (totrim == len)
    { str[0] = '\0'; } else
    {memmove(str, str + totrim, len + 1 - totrim);}
    }
    }


    int main(void)
    {

    //vars
    char delim[2] = ",";
    int i=0,j=0;

    //number of names is commas + 1 int namecnt = countchr(names,',')
    + 1;

    //name array: one column for first-last, one for last-first char
    *narr[2][namecnt];

    char *flname, lfname[30]; // full names char *fname,
    *lname; //
    part names char tmp[30]="";

    // parse full names from string // then parse first and last from
    full
    name // add both into array char *dup = strdup(names);
    while((flname = strsep(&dup,delim)) != NULL )
    {
    ltrim(flname);
    if(countchr(flname,' ')>0)
    {
    lname = strrchr(flname,' ')+1;
    memset(tmp, '\0', sizeof(tmp));
    strncat(tmp,flname,strlen(flname)-
    strlen(lname)-1);
    fname = strdup(tmp);
    }
    else {
    lname = strdup(flname);
    fname = strdup("");
    fname[strlen(fname)-2] = '\0';
    }

    sprintf(lfname,"%s %s",lname,fname); narr[0][i]=
    strdup(flname);
    narr[1][i]= strdup(lfname);
    i++;
    }


    //add list of last-first names into array then sort it char
    *sarr[namecnt];
    for(i=0;i<namecnt;i++) {sarr[i] = narr[1][i];}
    qsort(sarr, namecnt, sizeof(char*), comparechar);

    //print first-last in order by last-first for(i=0;i<namecnt;i++)
    {
    for(j=0;j<namecnt;j++)
    {
    if(narr[1][j] == sarr[i])
    {
    printf("%d %s\n",i+1, narr[0][j]);
    break;
    }
    }
    }

    return 0;
    }
    ------------------------------------------------------------------
    71 SLOC


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Sat Apr 18 11:22:27 2026
    On 16/04/2026 17:24, Bonita Montero wrote:

    ÿÿÿÿsort( names.begin(), names.end(), []( const name &lhs, const name
    &rhs ) { return lhs.second < rhs.second; } );


    I think this needs to be a case-insensitive sort.

    While the OP's data only had capitalised surnames (with one exception),
    their solution used a string-sensitive compare.

    The exception is the name "taishi28012". With your code, that name
    doesn't appear at all in the output.

    If I add a dummy first name to this, then it appears last of all the
    ASCII names, but before the Greek name.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Sat Apr 18 08:11:01 2026
    On 4/18/2026 5:16 AM, Rosario19 wrote:
    On Tue, 7 Apr 2026 23:14:41 -0400, DFS wrote:

    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower,
    Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast,
    James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson,
    Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken
    Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod
    Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ?????, Ron Lauzon, TheFred, Paul
    Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.
    ot

    this would be one APL program in "brace" form and its result, because
    here it seems is difficult print 2 chars chars

    s{leftarrow}{apostrophe}Martin Hohenberg, Jae Yang, Tim Bando,
    Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor,
    Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz,
    Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack,
    Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken
    LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale
    Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey
    Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark
    Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, {\x00CE}{\x2020}{\x00CF}{\x0081}{\x00CE}{\x00B7} {\x00CF}{\x201A}
    {\x00CE}{\x201D}{\x00CE}{\x00AC}{\x00CF}{\x0192}{\x00CE} {\x00BF}{\x00CF}{\x201A}, Ron Lauzon, TheFred, Paul Theodoropolous,
    Doug Phillips, Les Vogel, Matt Pollard, Andres
    Cordova{apostrophe}{cr}{lf}

    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}{leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}{leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}

    Mordant
    taishi28012
    darrin
    ReallyBored
    TheFred
    Paul Abbott
    Neil Anuskiewicz

    --------------------------------
    Tim Bando
    Masa Bando
    --------------------------------
    FAIL


    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry
    Arnold F. Williams
    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Sat Apr 18 14:03:30 2026
    On 18/04/2026 13:11, DFS wrote:
    On 4/18/2026 5:16 AM, Rosario19 wrote:
    On Tue, 7 Apr 2026 23:14:41 -0400, DFSÿ wrote:

    Martin Hohenberg, Jae Yang, Tim Bando, Daniel Garber, Kyle Burkholder,
    Mike Nichols, Mark Ping, Tom Taylor, Arnold F. Williams, George Brower,
    Michael Nygard, Brendan Long, Sven Dowideit, Dave Witten, Jonathan Cast, >>> James Cronin, David L. Jessup, Christopher Chang, Killer Delicious,
    Jacob Lyles, Neil Anuskiewicz, Mordant, Clemens Ladisch, Wojciech
    Woytniak, Masa Bando, John Carmack, Xingyu Wang, Jane Tang, Steven
    Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse, taishi28012, John Simpson, >>> Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald Greer, Gratiela
    Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood, Ken
    Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod
    Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas,
    Bill Soistman, ReallyBored, ???? ?????, Ron Lauzon, TheFred, Paul
    Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres Cordova


    Print first last (as shown above) but ordered by last first.
    ot

    this would be one APL program in "brace" form and its result, because
    here it seems is difficult print 2 chars chars

    ÿÿÿÿÿÿ s{leftarrow}{apostrophe}Martin Hohenberg, Jae Yang, Tim Bando,
    Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor,
    Arnold F. Williams, George Brower, Michael Nygard, Brendan Long, Sven
    Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L. Jessup,
    Christopher Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz,
    Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando, John Carmack,
    Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken
    LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott, Stan
    Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale
    Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey
    Sasser, Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark
    Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius
    Darjania, Cheryl Evry, Wenfeng Liang, Irving Rivas, Bill Soistman,
    ReallyBored, {\x00CE}{\x2020}{\x00CF}{\x0081}{\x00CE}{\x00B7}
    {\x00CF}{\x201A}
    {\x00CE}{\x201D}{\x00CE}{\x00AC}{\x00CF}{\x0192}{\x00CE}
    {\x00BF}{\x00CF}{\x201A}, Ron Lauzon, TheFred, Paul Theodoropolous,
    Doug Phillips, Les Vogel, Matt Pollard, Andres
    Cordova{apostrophe}{cr}{lf}

    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}
    {leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}
    {leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}
    {apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}

    ÿÿ Mordant
    ÿÿ taishi28012
    ÿÿ darrin
    ÿÿ ReallyBored
    ÿÿ TheFred
    ÿÿ Paul Abbott
    ÿÿ Neil Anuskiewicz

    --------------------------------
    ÿÿ Tim Bando
    ÿÿ Masa Bando
    --------------------------------
    FAIL

    So sorting presumably is case-sensitive, and last name first, then first
    names in order?

    You weren't entirely clear in your OP, where it only talks about first
    and last names, but some entries have only one name, and some have three.

    Perhaps some reference output should have been posted (I saw it
    somewhere but can't find in the thread, and don't know if it came from you).

    I posted a version in script code, but mistakenly in the cookie thread,
    when I got the idea that solutions in any language were allowed. That
    one sorted on last name only (but seems to get the Bandos in the right
    order somehow).


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Sat Apr 18 17:48:52 2026
    Am 18.04.2026 um 12:22 schrieb Bart:

    I think this needs to be a case-insensitive sort.

    While the OP's data only had capitalised surnames (with one exception), their solution used a string-sensitive compare.

    The exception is the name "taishi28012". With your code, that name
    doesn't appear at all in the output.

    If I add a dummy first name to this, then it appears last of all the
    ASCII names, but before the Greek name.

    Now everything is fine: surnames without forenames are handled and
    the search is case-insensitive.


    #include <iostream>
    #include <utility>
    #include <string_view>
    #include <regex>
    #include <vector>
    #include <algorithm>
    #include <compare>

    using namespace std;

    static constexpr const char *Names = "Martin Hohenberg, Jae Yang, Tim
    Bando, Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom
    Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long,
    Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L.
    Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil
    Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando,
    John Carmack, Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh
    Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott,
    Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser,
    Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova";

    int svicmp( string_view lhs, string_view rhs );

    int main()
    {
    string_view svNames = ::Names;
    regex
    rxTotal( "\\s*([^,]+)(?:,|$)" ),
    rxRvSurname( "\\s*(\\S+)" ),
    rxRvGap( "\\s+" );
    match_results<string_view::iterator> totalMtch;
    match_results<string_view::reverse_iterator> rvMatch;
    struct name { string_view forename, surname; };
    vector<name> names;
    for( auto itName = svNames.begin(); regex_search( itName, svNames.end(), totalMtch, rxTotal ); itName = totalMtch[0].second )
    {
    if( !regex_search( reverse_iterator( totalMtch[1].second ), reverse_iterator( totalMtch[1].first ), rvMatch, rxRvSurname ) )
    continue;
    auto
    itForename = totalMtch[1].first,
    itSurname = rvMatch[1].second.base(),
    itSurnameEnd = rvMatch[1].first.base();
    string_view surname( itSurname, itSurnameEnd ), forename;
    if( regex_search( reverse_iterator( itSurname ), reverse_iterator(
    itForename ), rvMatch, rxRvGap ) )
    forename = string_view( itForename, rvMatch[0].second.base() );
    else
    if( itSurname != itForename )
    continue;
    names.emplace_back( forename, surname );
    }
    sort( names.begin(), names.end(), []( const name &lhs, const name &rhs )
    {
    int cmpSurname = svicmp( lhs.surname, rhs.surname );
    if( cmpSurname != 0 )
    return cmpSurname < 0;
    return lhs.forename < rhs.forename;
    } );
    for( const name &nm : names )
    cout << "\"" << nm.surname << "\", \"" << nm.forename << "\"" << endl;
    }

    int svicmp( string_view lhs, string_view rhs )
    {
    constexpr auto *lwtoi = +[]( char c ) -> int { return (unsigned char)tolower( c ); };
    size_t c = min( lhs.size(), rhs.size() );
    for( size_t i = 0; i < c; ++i )
    if( int d = lwtoi( lhs[i] ) - lwtoi( rhs[i] ); d )
    return d;
    return lhs.size() < rhs.size();
    }



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Sun Apr 19 08:44:26 2026
    Now I've extracted the parsing part in a separate lambda. You cann
    call it with pars( true_type() ) if you wnat regex-parsing. You can
    call it with parse( false_type() ) if you want manual parsing (faster).

    #include <iostream>
    #include <utility>
    #include <string_view>
    #include <regex>
    #include <vector>
    #include <algorithm>
    #include <compare>

    using namespace std;

    static constexpr const char *Names = "Martin Hohenberg, Jae Yang, Tim
    Bando, Daniel Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom
    Taylor, Arnold F. Williams, George Brower, Michael Nygard, Brendan Long,
    Sven Dowideit, Dave Witten, Jonathan Cast, James Cronin, David L.
    Jessup, Christopher Chang, Killer Delicious, Jacob Lyles, Neil
    Anuskiewicz, Mordant, Clemens Ladisch, Wojciech Woytniak, Masa Bando,
    John Carmack, Xingyu Wang, Jane Tang, Steven Evans, Jan Roudaut, Hsueh
    Sung, Ken LaCrosse, taishi28012, John Simpson, Jerod Tufte, Paul Abbott,
    Stan Witherspoon, Donald Greer, Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis, Liudmilla Karukina, Jim McCloskey, Dewey Sasser,
    Hal Hildebrand, Connor Wood, Ken Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod Davenport, Nodarius Darjania, Cheryl
    Evry, Wenfeng Liang, Irving Rivas, Bill Soistman, ReallyBored, ????
    ??å??, Ron Lauzon, TheFred, Paul Theodoropolous, Doug Phillips, Les
    Vogel, Matt Pollard, Andres Cordova";

    int svicmp( string_view lhs, string_view rhs );

    int main()
    {
    string_view svNames = ::Names;
    struct name { string_view forename, surname; };
    vector<name> names;
    auto parse = [&]<bool Regex>( bool_constant<Regex> )
    {
    if constexpr( Regex )
    {
    regex
    rxTotal( "\\s*([^,]+)(?:,|$)" ),
    rxRvSurname( "\\s*(\\S+)" ),
    rxRvGap( "\\s+" );
    match_results<string_view::iterator> totalMtch;
    match_results<string_view::reverse_iterator> rvMatch;
    for( auto itName = svNames.begin(); regex_search( itName,
    svNames.end(), totalMtch, rxTotal ); itName = totalMtch[0].second )
    {
    if( !regex_search( reverse_iterator( totalMtch[1].second ),
    reverse_iterator( totalMtch[1].first ), rvMatch, rxRvSurname ) )
    continue;
    auto
    itForename = totalMtch[1].first,
    itSurname = rvMatch[1].second.base(),
    itSurnameEnd = rvMatch[1].first.base();
    string_view surname( itSurname, itSurnameEnd ), forename;
    if( regex_search( reverse_iterator( itSurname ), reverse_iterator(
    itForename ), rvMatch, rxRvGap ) )
    forename = string_view( itForename, rvMatch[0].second.base() );
    else
    if( itSurname != itForename )
    continue;
    names.emplace_back( forename, surname );
    }
    }
    else
    {
    for( auto where = svNames.begin(); where != svNames.end(); )
    {
    static constexpr auto *whitespace = +[]( char c ) { return c == ' '
    || c == '\t' || c == '\r' || c == '\n'; };
    static constexpr auto *nonWs = +[]( char c ) { return !whitespace( c
    ); };
    auto
    itNameBegin = where,
    itNameEnd = find( itNameBegin, svNames.end(), ',' );
    if( itNameEnd == itNameBegin )
    break;
    where = itNameEnd + (itNameEnd != svNames.end());
    auto itSurnameEnd = find_if( reverse_iterator( itNameEnd ),
    reverse_iterator( itNameBegin ), nonWs ).base();
    if( itSurnameEnd == itNameBegin )
    continue;
    auto itSurname = find_if( reverse_iterator( itSurnameEnd ),
    reverse_iterator( itNameBegin ), whitespace ).base();
    string_view surname( itSurname, itSurnameEnd ), forename;
    auto
    itForenameEnd = find_if( reverse_iterator( itSurname ),
    reverse_iterator( itNameBegin ), nonWs ).base(),
    itForenameBegin = find_if( itNameBegin, itForenameEnd, nonWs );
    forename = string_view( itForenameBegin, itForenameEnd );
    names.emplace_back( forename, surname );
    }
    }
    };
    parse( false_type() );
    sort( names.begin(), names.end(), []( const name &lhs, const name &rhs )
    {
    int cmpSurname = svicmp( lhs.surname, rhs.surname );
    if( cmpSurname != 0 )
    return cmpSurname < 0;
    return svicmp( lhs.forename, rhs.forename ) < 0;
    } );
    for( const name &nm : names )
    cout << "\"" << nm.surname << "\", \"" << nm.forename << "\"" << endl;
    }

    int svicmp( string_view lhs, string_view rhs )
    {
    constexpr auto *lwtoi = +[]( char c ) -> int { return (unsigned char)tolower( c ); };
    size_t c = min( lhs.size(), rhs.size() );
    for( size_t i = 0; i < c; ++i )
    if( int d = lwtoi( lhs[i] ) - lwtoi( rhs[i] ); d )
    return d;
    return lhs.size() < rhs.size();
    }

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Mon Apr 20 21:20:28 2026
    On Sat, 18 Apr 2026 11:16:48 +0200, Rosario19 wrote:

    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}{leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}{leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}

    Mordant
    taishi28012
    darrin
    ReallyBored
    TheFred
    Paul Abbott
    Neil Anuskiewicz
    Tim Bando
    Masa Bando
    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry
    Arnold F. Williams
    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang


    this is a C version

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>

    #define R return
    #define P printf

    char names[] = {"Martin Hohenberg, Jae Yang, Tim Bando, Daniel \
    Garber, Kyle Burkholder, Mike Nichols, Mark Ping, Tom Taylor, Arnold
    F. \
    Williams, George Brower, Michael Nygard, Brendan Long, Sven Dowideit,
    \
    Dave Witten, Jonathan Cast, James Cronin, David L. Jessup, Christopher
    \
    Chang, Killer Delicious, Jacob Lyles, Neil Anuskiewicz, Mordant,
    Clemens \
    Ladisch, Wojciech Woytniak, Masa Bando, John Carmack, Xingyu Wang,
    Jane \
    Tang, Steven Evans, Jan Roudaut, Hsueh Sung, Ken LaCrosse,
    taishi28012, \
    John Simpson, Jerod Tufte, Paul Abbott, Stan Witherspoon, Donald
    Greer, \
    Gratiela Chergu, Michael Ciagala, Dale Carstensen, Chip Davis,
    Liudmilla \
    Karukina, Jim McCloskey, Dewey Sasser, Hal Hildebrand, Connor Wood,
    Ken \
    Kennedy, darrin, Mark Gardner, William Christensen, Malcolm Ocean, Rod
    \
    Davenport, Nodarius Darjania, Cheryl Evry, Wenfeng Liang, Irving
    Rivas, \
    Bill Soistman, ReallyBored, Ron Lauzon, TheFred, Paul \
    Theodoropolous, Doug Phillips, Les Vogel, Matt Pollard, Andres
    Cordova"};

    int toNextWord(char* a)
    {int k,c,cnt;
    if(a[0]==0) R 0;
    if(a[1]==0||a[1]==',') R 0;
    k=0;
    if(a[k]==',')++k;
    for(cnt=0;c=a[k];++k)
    {if(c==0||c==',') R 0;
    if(isalnum(c))
    {if(cnt==1) R k;
    for(++cnt;isalnum(c=a[k]);++k);
    if(c==','||c==0)R 0;
    }
    }
    R 0;
    }

    char** rompiVettori(char* a)
    {int i, c, cnt, j, k;
    char **p, pc;

    for(i=0,cnt=0;c=a[i];++i)
    {if(c==',')++cnt;if(i>2e6||cnt>2e4) R 0;}
    cnt+=8;p=(char**)malloc(cnt*sizeof(char*));if(p==0) R 0;
    p[0]=a;
    for(i=0,j=1;c=a[i];++i)
    {if(c==',')p[j++]=a+i;
    if(i>2e6||j>2e4){free(p); R 0;}
    }
    k=j;
    for(j=0;j<k;++j)
    {i=toNextWord(p[j]);
    p[j]=p[j]+i;
    //P("%x %c%c ",p[j],p[j][0], p[j][1]);
    }
    p[j]=0;
    R p;
    }

    int wordcmp(const void* aa, const void* bb)
    {int ca,cb,i,j;
    char *a=*(char**)aa, *b=*(char**)bb;

    if(a==0)R -1;
    if(b==0)R 1;
    //P("%x %x\n", a, b);
    if(!isalnum(*a))R -1;
    if(!isalnum(*b))R 1;
    for(i=0;(ca=a[i])&&(cb=b[i]);++i)
    {if(!isalnum(ca)) R -1;
    if(!isalnum(cb)) R 1;
    ca=toupper(ca); cb=toupper(cb);
    if(ca<cb)R -1;
    if(ca>cb)R 1;
    }
    R -1;
    }

    int main()
    {int i,j,c;
    char **p=rompiVettori(names), *pc, *pf;

    if(p==0)R 0;

    for(j=0;names[j];++j);
    pf=names+j;

    /*
    P("fine=%x p=%x\n", pf,p);
    P("p[0]=%x names=%x\n", p[0], names);
    for(i=0;p[i];++i)
    P("%c%c ", p[i][0], p[i][1]);
    P("i=%d\n", i);
    */

    for(i=0;p[i];++i)
    ;
    qsort(p,i,sizeof(char*),wordcmp);

    for(i=0;p[i];++i)
    {for(pc=p[i];pc>names;--pc)
    if(*pc==',')break;
    if(*pc==',')++pc;
    for(j=0;pc+j<pf&&isspace(pc[j]);++j);
    for(;pc+j<pf&&(c=pc[j])&&','!=c;++j)
    {P("%c", c);}
    P("\n");
    }

    free(p);
    return 0;
    }

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz
    Tim Bando
    Masa Bando
    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry
    Arnold F. Williams
    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Mon Apr 20 16:43:28 2026
    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail


    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry

    ------------------------
    Arnold F. Williams
    ------------------------
    fail


    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Mon Apr 20 14:16:30 2026
    Rosario19 <Ros@invalid.invalid> writes:
    [...]

    this is a C version

    [...]

    #define R return
    #define P printf

    Nope.

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Tue Apr 21 05:00:56 2026
    On Sat, 18 Apr 2026 11:16:48 +0200, Rosario19 wrote:

    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}{leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}{leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}


    {commabar}{leftbrace}k[{deltastile}{rightshoe}{uparrow}{dieresis}{leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}k{leftarrow}{leftbrace}({omega}{notequal}{apostrophe}
    {apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}]{rightbrace}s{cr}{lf}

    they are 40 chars if one not count input lenght and the assignament to
    a varible of it.

    The comment:

    ?{k[????{1??}?k?{(??' ')??}?(??',')??]}s
    s input -------------------------------------------------- ({omega}{notequal}{apostrophe},{apostrophe}){leftshoe}{omega}
    (??',')?? break the input s=? in the
    way each element is a string that contain elements between ,, -------------------------------------------------- {leftbrace}({omega}{notequal}{apostrophe}{apostrophe}){leftshoe}{omega}{rightbrace}{dieresis}
    {(??' ')??}? break each element of
    elements the above result array for separate name and surname --------------------------------------------------
    k{leftarrow}
    k?
    call that k, k is a list contain elements as ('firstName',
    'secondname')
    -------------------------------------------------- {leftbrace}1{downarrow}{omega}{rightbrace}{dieresis}
    {1??}? from each element of k, cut
    the first
    --------------------------------------------------
    {uparrow}{dieresis}
    ?? so remain the second...
    disclose it
    --------------------------------------------------
    {rightshoe}
    ? build one matrix of the second names this is
    only because ? return indices ordered lexicographic on lines --------------------------------------------------
    {deltastile}
    ? order indices --------------------------------------------------
    {k[?..........] show k of these index --------------------------------------------------
    {commabar}
    ? show one name surname for line

    for me in APL the process of programming is show in the screen each
    change of input using the next function (or imagine that)
    in C the same.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Tue Apr 21 05:06:54 2026
    On Tue, 21 Apr 2026 05:00:56 +0200, Rosario19 wrote:

    for me in APL the process of programming is show in the screen each
    change of input using the next function (or imagine that)
    in C the same.

    In C there is to think more than APL for edge cases that can happen

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Tue Apr 21 05:09:56 2026
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second
    name. So that is all UB

    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry

    ------------------------
    Arnold F. Williams
    ------------------------
    fail

    the spec.. not speak about if the second names is just F. so F is a
    valid second name.


    Daniel Garber
    Mark Gardner
    Donald Greer
    Hal Hildebrand
    Martin Hohenberg
    Liudmilla Karukina
    Ken Kennedy
    David L. Jessup
    Ken LaCrosse
    Clemens Ladisch
    Ron Lauzon
    Wenfeng Liang
    Brendan Long
    Jacob Lyles
    Jim McCloskey
    Mike Nichols
    Michael Nygard
    Malcolm Ocean
    Doug Phillips
    Mark Ping
    Matt Pollard
    Irving Rivas
    Jan Roudaut
    Dewey Sasser
    John Simpson
    Bill Soistman
    Hsueh Sung
    Jane Tang
    Tom Taylor
    Paul Theodoropolous
    Jerod Tufte
    Les Vogel
    Xingyu Wang
    Stan Witherspoon
    Dave Witten
    Connor Wood
    Wojciech Woytniak
    Jae Yang



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Tue Apr 21 08:46:10 2026
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second
    name. So that is all UB

    The 'spec' was clear: order by last, first.


    George Brower
    Kyle Burkholder
    John Carmack
    Dale Carstensen
    Jonathan Cast
    Christopher Chang
    Gratiela Chergu
    William Christensen
    Michael Ciagala
    Andres Cordova
    James Cronin
    Nodarius Darjania
    Rod Davenport
    Chip Davis
    Killer Delicious
    Sven Dowideit
    Steven Evans
    Cheryl Evry

    ------------------------
    Arnold F. Williams
    ------------------------
    fail

    the spec.. not speak about if the second names is just F. so F is a
    valid second name.


    "Williams" is the last name, not the second name.

    The 'spec' was clear: order by last, first.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Tue Apr 21 13:00:30 2026
    In article <10s653e$11uo1$1@kst.eternal-september.org>,
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    Rosario19 <Ros@invalid.invalid> writes:
    [...]

    this is a C version

    [...]

    #define R return
    #define P printf

    Nope.

    [...]

    I think they put stuff like that in their postings just to piss you off.

    They know how easy it is to light you up.

    --
    Never, ever, ever forget that "Both sides do it" is strictly a Republican meme.

    It is always the side that sucks that insists on saying "Well, you suck, too".


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Tue Apr 21 16:08:13 2026
    On 21/04/2026 13:46, DFS wrote:
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second
    name. So that is all UB

    The 'spec' was clear: order by last, first.

    The spec didn't mention case-sensitive compare.

    It didn't mention what happens when there is one name.

    It didn't mention what happens when there are three or more names, or
    middle initials.

    It didn't say anything about how much white space, or how much less,
    could be anticipated. So any new input that varies from your example
    might not work.

    It didn't give any examples of what the output needs to look, at least
    not in your OP. (They can see it by running your submission, but it says
    no peeking.)



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Tue Apr 21 11:33:19 2026
    On 4/21/2026 11:08 AM, Bart wrote:
    On 21/04/2026 13:46, DFS wrote:
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second
    name. So that is all UB

    The 'spec' was clear: order by last, first.

    The spec didn't mention case-sensitive compare.

    It didn't mention what happens when there is one name.

    It didn't mention what happens when there are three or more names, or
    middle initials.
    It didn't say anything about how much white space, or how much less,
    could be anticipated. So any new input that varies from your example
    might not work.

    It didn't give any examples of what the output needs to look, at least
    not in your OP. (They can see it by running your submission, but it says
    no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask you to
    do. "Sort this list by last name then first name" is all I would expect
    to get. Asking about case-sensitivity and 4 names and whitespace would
    make you look like a ninny.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Tue Apr 21 18:25:47 2026
    On 21/04/2026 16:33, DFS wrote:
    On 4/21/2026 11:08 AM, Bart wrote:
    On 21/04/2026 13:46, DFS wrote:
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second >>>> name. So that is all UB

    The 'spec' was clear: order by last, first.

    The spec didn't mention case-sensitive compare.

    It didn't mention what happens when there is one name.

    It didn't mention what happens when there are three or more names, or
    middle initials.
    It didn't say anything about how much white space, or how much less,
    could be anticipated. So any new input that varies from your example
    might not work.

    It didn't give any examples of what the output needs to look, at least
    not in your OP. (They can see it by running your submission, but it
    says no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask you to
    do.ÿ "Sort this list by last name then first name" is all I would expect
    to get.ÿ Asking about case-sensitivity and 4 names and whitespace would
    make you look like a ninny.


    So you don't care? Then your specification is sloppy.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Tue Apr 21 17:38:03 2026
    Bart <bc@freeuk.com> writes:
    On 21/04/2026 16:33, DFS wrote:
    On 4/21/2026 11:08 AM, Bart wrote:


    It didn't give any examples of what the output needs to look, at least
    not in your OP. (They can see it by running your submission, but it
    says no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask you to
    do.ÿ "Sort this list by last name then first name" is all I would expect
    to get.ÿ Asking about case-sensitivity and 4 names and whitespace would
    make you look like a ninny.

    You seem to be confusing a comic strip with reality.

    In the real world, for professional developers, detailed
    specifications are common. Forty years ago, detailed
    specifications were common (we had three levels of
    specification for each project back in 1983; a concept
    spec, a detailed specification and a test specification).

    Even the two startups I've been associated with had clear
    and concise specifications for each project.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Tue Apr 21 20:50:19 2026
    On Tue, 21 Apr 2026 17:38:03 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 21/04/2026 16:33, DFS wrote:
    On 4/21/2026 11:08 AM, Bart wrote:


    It didn't give any examples of what the output needs to look, at
    least not in your OP. (They can see it by running your
    submission, but it says no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask
    you to do.ÿ "Sort this list by last name then first name" is all
    I would expect to get.ÿ Asking about case-sensitivity and 4 names
    and whitespace would make you look like a ninny.

    You seem to be confusing a comic strip with reality.

    In the real world, for professional developers, detailed
    specifications are common. Forty years ago, detailed
    specifications were common (we had three levels of
    specification for each project back in 1983; a concept
    spec, a detailed specification and a test specification).

    Even the two startups I've been associated with had clear
    and concise specifications for each project.


    Methinks, the segment of the industry that employed you for last nn
    (40?) years is an exception rather than rule.
    In industry as a whole imprecise specs are far more common. Also, specs
    are not constant. If the software is user-facing then the biggest batch
    of clarifications of the spec tend to come after alpha version was
    shipped to friendly customers. But even after that if the project is
    not dead then there tends to be continuous flow of changes and
    clarifications of specs.



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Tue Apr 21 18:22:21 2026
    Michael S <already5chosen@yahoo.com> writes:
    On Tue, 21 Apr 2026 17:38:03 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bart <bc@freeuk.com> writes:
    On 21/04/2026 16:33, DFS wrote: =20
    On 4/21/2026 11:08 AM, Bart wrote: =20
    =20

    It didn't give any examples of what the output needs to look, at
    least not in your OP. (They can see it by running your
    submission, but it says no peeking.) =20
    =20
    =20
    You don't really need all that handholding do you?
    =20
    None of those issues would be typical of what the PHB would ask
    you to do.=C2=A0 "Sort this list by last name then first name" is all
    I would expect to get.=C2=A0 Asking about case-sensitivity and 4 names
    and whitespace would make you look like a ninny. =20
    =20
    You seem to be confusing a comic strip with reality.
    =20
    In the real world, for professional developers, detailed
    specifications are common. Forty years ago, detailed
    specifications were common (we had three levels of
    specification for each project back in 1983; a concept
    spec, a detailed specification and a test specification).
    =20
    Even the two startups I've been associated with had clear
    and concise specifications for each project.
    =20

    Methinks, the segment of the industry that employed you for last nn
    (40?) years is an exception rather than rule.

    Computer system manufacturers and fabless semiconductor
    companies. Mainframes, Minicomputers, MPP machines, complex SOCs.

    Operating systems, hypervisors, simulators, firmware.

    Granted, I've never worked in web services space (aside a
    couple of years at the dot-com bust spent working on a Java-based B2B XML data-flow engine with some of the ex-SUN Java developers).


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Apr 21 12:21:51 2026
    On 4/21/2026 6:00 AM, Kenny McCormack wrote:
    In article <10s653e$11uo1$1@kst.eternal-september.org>,
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    Rosario19 <Ros@invalid.invalid> writes:
    [...]

    this is a C version

    [...]

    #define R return
    #define P printf

    Nope.

    [...]

    I think they put stuff like that in their postings just to piss you off.

    They know how easy it is to light you up.


    Humm... I have tried to abstract away using macros. So, for say, ct_np_x86_foo_bar,

    #define ct_foo_bar ct_np_x86_foo_bar

    ?

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From DFS@3:633/10 to All on Tue Apr 21 16:31:40 2026
    On 4/21/2026 1:25 PM, Bart wrote:
    On 21/04/2026 16:33, DFS wrote:
    On 4/21/2026 11:08 AM, Bart wrote:
    On 21/04/2026 13:46, DFS wrote:
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the second >>>>> name. So that is all UB

    The 'spec' was clear: order by last, first.

    The spec didn't mention case-sensitive compare.

    It didn't mention what happens when there is one name.

    It didn't mention what happens when there are three or more names, or
    middle initials.
    It didn't say anything about how much white space, or how much less, >>> could be anticipated. So any new input that varies from your example
    might not work.

    It didn't give any examples of what the output needs to look, at
    least not in your OP. (They can see it by running your submission,
    but it says no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask you to
    do.ÿ "Sort this list by last name then first name" is all I would
    expect to get.ÿ Asking about case-sensitivity and 4 names and
    whitespace would make you look like a ninny.


    So you don't care? Then your specification is sloppy.

    You misspelled realistic.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Tue Apr 21 23:04:49 2026
    On 21/04/2026 21:31, DFS wrote:
    On 4/21/2026 1:25 PM, Bart wrote:
    On 21/04/2026 16:33, DFS wrote:
    On 4/21/2026 11:08 AM, Bart wrote:
    On 21/04/2026 13:46, DFS wrote:
    On 4/20/2026 11:09 PM, Rosario19 wrote:
    On Mon, 20 Apr 2026 16:43:28 -0400, DFS wrote:

    On 4/20/2026 3:20 PM, Rosario19 wrote:

    this is a C version

    <snip>

    ---------------------------------
    result:
    ---------------------------------
    TheFred
    taishi28012
    darrin
    ReallyBored
    Mordant
    Paul Abbott
    Neil Anuskiewicz


    ------------------
    Tim Bando
    Masa Bando
    ------------------
    fail

    the spec.. not speak about order by first name but only for the
    second
    name. So that is all UB

    The 'spec' was clear: order by last, first.

    The spec didn't mention case-sensitive compare.

    It didn't mention what happens when there is one name.

    It didn't mention what happens when there are three or more names, or
    middle initials.
    It didn't say anything about how much white space, or how much
    less,
    could be anticipated. So any new input that varies from your example
    might not work.

    It didn't give any examples of what the output needs to look, at
    least not in your OP. (They can see it by running your submission,
    but it says no peeking.)


    You don't really need all that handholding do you?

    None of those issues would be typical of what the PHB would ask you
    to do.ÿ "Sort this list by last name then first name" is all I would
    expect to get.ÿ Asking about case-sensitivity and 4 names and
    whitespace would make you look like a ninny.


    So you don't care? Then your specification is sloppy.

    You misspelled realistic.

    If there is no proper spec then here's my submission:

    #include <stdio.h>

    int main() {
    puts(
    "1 Paul Abbott\n"
    "2 Neil Anuskiewicz\n"
    "3 Masa Bando\n"
    "4 Tim Bando\n"
    "5 George Brower\n"
    "6 Kyle Burkholder\n"
    "7 John Carmack\n"
    "8 Dale Carstensen\n"
    "9 Jonathan Cast\n"
    "10 Christopher Chang\n"
    "11 Gratiela Chergu\n"
    "12 William Christensen\n"
    "13 Michael Ciagala\n"
    "14 Andres Cordova\n"
    "15 James Cronin\n"
    "16 Nodarius Darjania\n"
    "17 darrin\n"
    "18 Rod Davenport\n"
    "19 Chip Davis\n"
    "20 Killer Delicious\n"
    "21 Sven Dowideit\n"
    "22 Steven Evans\n"
    "23 Cheryl Evry\n"
    "24 Daniel Garber\n"
    "25 Mark Gardner\n"
    "26 Donald Greer\n"
    "27 Hal Hildebrand\n"
    "28 Martin Hohenberg\n"
    "29 David L. Jessup\n"
    "30 Liudmilla Karukina\n"
    "31 Ken Kennedy\n"
    "32 Ken LaCrosse\n"
    "33 Clemens Ladisch\n"
    "34 Ron Lauzon\n"
    "35 Wenfeng Liang\n"
    "36 Brendan Long\n"
    "37 Jacob Lyles\n"
    "38 Jim McCloskey\n"
    "39 Mordant\n"
    "40 Mike Nichols\n"
    "41 Michael Nygard\n"
    "42 Malcolm Ocean\n"
    "43 Doug Phillips\n"
    "44 Mark Ping\n"
    "45 Matt Pollard\n"
    "46 ReallyBored\n"
    "47 Irving Rivas\n"
    "48 Jan Roudaut\n"
    "49 Dewey Sasser\n"
    "50 John Simpson\n"
    "51 Bill Soistman\n"
    "52 Hsueh Sung\n"
    "53 taishi28012\n"
    "54 Jane Tang\n"
    "55 Tom Taylor\n"
    "56 TheFred\n"
    "57 Paul Theodoropolous\n"
    "58 Jerod Tufte\n"
    "59 Les Vogel\n"
    "60 Xingyu Wang\n"
    "61 Arnold F. Williams\n"
    "62 Stan Witherspoon\n"
    "63 Dave Witten\n"
    "64 Connor Wood\n"
    "65 Wojciech Woytniak\n"
    "66 Jae Yang\n"
    "67 ???? ??å??\n"
    );
    }



    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)