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)