Skip to content

Problems with your sort example when used with mixed language #1

@Bancherd-DeLong

Description

@Bancherd-DeLong

I tried your example for sorting from largest to smallest:
cat dictionary.txt | awk '{ print length, $0 }' | sort -g -r | cut -d" " -f2 > sorted_dictionary.txt

with the example text:
A
A รหัส A
AB
ABC

and the result is:
A
ABC
AB
A

with "รหัส A" deleted.

A possible kludge that I came up is:
cat dictionary.txt | awk '{ print length, $0 }' | sort -g -r | sed 's/^ *//' | cut -d" " -f2- > sorted_dictionary.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions