in reply to Changing ASCII collating sequence for sort

I think your problem might be that in the tr/.../.../ operator inside your sort block, you forgot to put a backslash-escape in front of the hyphen characters.

When used within the left or right side of the tr/// operator, hyphen is "magic": it interpolates to the set of characters between the preceding and following character, so ,-; (in the left-hand character sequence) becomes ,-.\/0123456789:;

(and in the right-hand sequence, ,-. "becomes" ,-. because ASCII arranges those three characters as adjacent in exactly that order, so putting the backslash escape in front of that hyphen just happens to make no difference)

Replies are listed 'Best First'.
Re^2: Changing ASCII collating sequence for sort
by ibm1620 (Hermit) on Apr 17, 2022 at 23:38 UTC
    This neatened it up a bit ...
    my @sorted_list = sort { tl($a) cmp tl($b) } @list; sub tl { return shift =~ tr / .,\-;:!?"'`_#$%&*+\/|=@\\^~()<>[]{}0123456789AaBbCcDdEeF +fGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz / -~/r; }
Re^2: Changing ASCII collating sequence for sort
by ibm1620 (Hermit) on Apr 17, 2022 at 23:20 UTC
    Precisely. Thanks!