5 ms·
How do you extract the last (largest) entry for each normalized key from the sorted list? What is the command line function?
by ChancyChance 3y ago
How do you extract the last (largest) entry for each normalized key from the sorted list? What is the command line function?
- hnfong 3y agoIt can be a simple ~20 line C program that checks whether the previous line has the same normalized key as the current line. It doesn't require hashing. I didn't say you could do it all with standard unix programs.
- layer8 3y agoYou pipe the sorted list into awk (for example) and append the second field to a list as long as the value of the first field remains the same. Whenever the value of the first field changes, and in the END block, you output the list (which contains the matching anagrams) and reset it to empty. No hash table needed, just splitting the line into the two fields, equality comparison, and appending values to a list.