In python I can sort a list like this...
lines = ["C: fish house bridge chocolate",
"C: hamster pen flower penny",
"C: dog park car paper",
"C: hamster pen bus tank",
"C: hamster lolly stick shirt"]
lines = sorted(lines)
for line in lines:
print (line)
Gives...
C: dog park car paper
C: fish house bridge chocolate
C: hamster lolly stick shirt
C: hamster pen bus tank
C: hamster pen flower penny
I can also sort by a particular column...
lines = sorted(lines, key=lambda line: line.split()[1])
for line in lines:
print (line)
Gives...
C: dog park car paper
C: fish house bridge chocolate
C: hamster pen flower penny
C: hamster pen bus tank
C: hamster lolly stick shirt
How can I remove lines so that the combined 2nd and 3rd columns of each line are unique?
Desired output would be...
C: dog park car paper
C: fish house bridge chocolate
C: hamster pen bus tank
C: hamster lolly stick shirt
In awk I could use something like !seen...
awk '!seen[$1][$2][$3]++'
What about in python?