I have text file with parse logged file, file contains: file: output.log End result should be: 1. sorted the list with max number
rt01,te1/1,111,11
rt02,te1/1,11,10
rt01,te1/2,122,20
rt02,te1/2,113,5
rt02,te1/3,10,1
rt03,te1/1,1,6
rt03,te1/2,11,8
Result:
rt01,te1/2,122,20
rt01,te1/1,111,11
rt02,te1/1,11,10
rt03,te1/2,11,8
rt03,te1/1,1,6
rt02,te1/2,113,5
rt02,te1/3,10,1
What is the best way, to get the max value within the list:
I try:
results = []
top = []
bottom = []
found = 0
with open('Python/output.log', 'r') as f:
for line in f:
    line = line.split(",")
    results.append(line)
print results
for i,j in enumerate(results[:-1]):
    #print results[i+1][3]
    if j[3] > results[i+1][3]:
        top.append(j)
    elif results[i+1][3] > top[3]:
        bottom.append(results[i+1])
        if top[i-1][3] > results[i+1][3]:
            top.append(j.pop())
            bottom.append(j)
            #top.append(j[])
print(top)
print(bottom)
 
     
     
    