Timeline for What's the best way to sort?
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 12, 2017 at 13:34 | comment | added | Sadi |
Thanks a lot. I think from now on I'll use this simpler version as a better alternative to the command sort -u ( having passed a though test with flying colors :-) And the first one as a script to create word lists out of text files :-)
|
|
| Jul 12, 2017 at 13:15 | comment | added | muru |
@Sadi If splitting the lines is not needed, then it's considerably simpler: python3 -c 'import sys; print("".join(sorted(set(sys.stdin))))'
|
|
| Jul 12, 2017 at 13:10 | comment | added | Sadi | May I also ask which part to take out in order to sort unique lines only, i.e. without replacing all spacing with line breaks? | |
| Jul 12, 2017 at 12:56 | comment | added | Sadi | Wov! Now even the duplicate 0 is gone, and it also looks better than LO Calc! Thanks a lot... | |
| Jul 12, 2017 at 12:42 | comment | added | muru |
@Sadi Oh, yeah, the output is unsorted. Note that I just used the set data structure to get unique elements, I didn't bother with sorting. I updated the first command to do some sorting, but I'm not sure if the output is what you want.
|
|
| Jul 12, 2017 at 12:41 | history | edited | muru | CC BY-SA 3.0 |
added 8 characters in body
|
| Jul 12, 2017 at 12:37 | comment | added | Sadi | For the record: This gave me a file with 933 lines, which looks more like it, with only one exception, as far as I can see: two zeros. However, sorting is not very smart. For instance, emoticons, number in circles, etc. are scattered all over the place. But I've managed to get closer to perfection when I copied it to LibreOffice Calc and sorted them - which grouped all emoticons together, and sorted all sorts of numbers in circles, etc. quite smartly :-) | |
| Jul 12, 2017 at 12:12 | comment | added | Sadi | I should have tried it first ;-) It works! Thanks a lot. | |
| Jul 12, 2017 at 12:11 | vote | accept | Sadi | ||
| Jul 12, 2017 at 12:10 | comment | added | muru | @Sadi Yes. The python command is reading from stdin, so you can pick your favourite way to send files to the stdin of a command. Or you could loop over arguments in Python itself. | |
| Jul 12, 2017 at 12:08 | comment | added | Sadi | Great! But ( as an average user ; -) how can I apply this script to a file please? Replace "bar" at the end with the file name? Actually I intend to make a nautilus/nemo script out of this, if I can. | |
| Jul 12, 2017 at 11:00 | history | answered | muru | CC BY-SA 3.0 |