[Python] RuleBasedCollator rule ignored

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to use the icu RuleBasedCollator in python. In my code I specify a rule wherby "ä" should sort before "a" as a secondary (accent) difference

    from icu import RuleBasedCollator

    l=["a","ä"]
    rbc = RuleBasedCollator('\n&ä<<a')
    sorted(l, key=rbc.getSortKey)



    However, the output of the sorted is:

    ['a', 'ä']

    I expected: ['ä','a'] What did I do wrong?

    Many thanks

    Continue reading...

Compartilhe esta Página