Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bancherd-DeLong opened this issue Mar 27, 2020 · 1 comment
Open

Comments

@Bancherd-DeLong
Copy link

Bancherd-DeLong commented Mar 27, 2020

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

@p16i
Copy link
Collaborator

p16i commented Apr 1, 2020

Hi,

Sorry for my late reply. Yeah, I assumed that words in the dictionary don't contain spaces.

Would you mind submitting a PR for updating README.md?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants