Forums before death by AOL, social media and spammers... "We can't have nice things"
|    rec.arts.sf.fandom    |    Discussions of SF fan activities    |    137,311 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 137,184 of 137,311    |
|    Lawrence =?iso-8859-13?q?D=FFOlivei to All    |
|    Re: AKICIF: Capitalizing Book Titles    |
|    17 Jan 26 08:43:39    |
   
   From: ldo@nz.invalid   
      
   On Fri, 16 Jan 2026 21:14:33 -0000 (UTC), Lawrence D’Oliveiro wrote:   
      
   >> On Fri, 16 Jan 2026 11:31:29 -0500, Evelyn C. Leeper wrote:   
   >>   
   >>> In 2010, the Academia Real Española declared that 'ch' and 'll'   
   >>> were no longer letters in their own right, but digraphs (like 'ph'   
   >>> in English). As such words with 'ch' would be alphabetized after   
   >>> 'cg' and before 'ci', and those with 'll' would have that between   
   >>> 'lk' and 'lm'.   
   >>>   
   >>> I personally think this was because computers could not handle   
   >>> them as single letters, and sort algorithms in particular would   
   >>> just break.   
   >>   
   >> It’s not the computers at fault, it’s the programmers who don’t   
   >> know to write text-processing code that caters for different   
   >> languages.   
   >   
   > Not the programmers fault. It's a problem using ASCII (or EBCDIC)   
   > rather than unicode.   
      
   It’s the programmer’s fault. As proof, here is some code that   
   implements the old rule. (Sorry I don’t know any actual Spanish words,   
   so I just made up some dummy text using those character sequences.)   
      
    def custom_sort_key(s) :   
    "generates a sort key for the string s, by splitting it into" \   
    " segments at instances of the character sequences to be treated" \   
    " specially."   
    key = []   
    while True :   
    positions = list \   
    (   
    (c1, c2, pos)   
    for c1, c2 in (("c", "h"), ("l", "l"))   
    for pos in (s.find(c1),)   
    if pos >= 0   
    )   
    if len(positions) == 0 :   
    key.append(s)   
    break   
    #end if   
    positions.sort(key = lambda e : e[1])   
    c1, c2, pos = positions[0]   
    # whichever occurs earliest   
    if pos > 0 :   
    key.append(s[:pos])   
    #end if   
    s = s[pos + 1:]   
    if len(s) != 0 and s[0] == c2 :   
    key.append(c1 + chr(0))   
    # ensure it sorts before other instances of c1   
    s = s[1:]   
    else :   
    key.append(c1 + chr(127))   
    # ensure it sorts after other instances of c1   
    #end if   
    if len(s) == 0 :   
    break   
    #end while   
    return key   
    #end custom_sort_key   
      
    text = ["xxlkxx", "xxcgxx", "xxllxx", "xxchxx", "xxlmxx", "xxcixx"]   
    print("input", text)   
    for t in text :   
    print("sort %s => %s" % (repr(t), repr(custom_sort_key(t))))   
    #end for   
    text.sort(key = custom_sort_key)   
    print("sorted", text)   
      
   Output:   
      
    input ['xxlkxx', 'xxcgxx', 'xxllxx', 'xxchxx', 'xxlmxx', 'xxcixx']   
    sort 'xxlkxx' => ['xx', 'l\x7f', 'kxx']   
    sort 'xxcgxx' => ['xx', 'c\x7f', 'gxx']   
    sort 'xxllxx' => ['xx', 'l\x00', 'xx']   
    sort 'xxchxx' => ['xx', 'c\x00', 'xx']   
    sort 'xxlmxx' => ['xx', 'l\x7f', 'mxx']   
    sort 'xxcixx' => ['xx', 'c\x7f', 'ixx']   
    sorted ['xxchxx', 'xxcgxx', 'xxcixx', 'xxllxx', 'xxlkxx', 'xxlmxx']   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca