I have a program that works on a logfile to narrow it down to two items. The program works great except that sometimes it gets the two numbers backwards. For example, the two numbers it ends up with should be something like [1700, 1650], not [1650, 1700]. How can I make sure the higher value number is listed first [0] and the lower number listed second [1]?
import pylab
from pylab import *
from numpy import *
from collections import Counter
list_of_files=[('logfile.txt', 'Temp')]
datalist = [( pylab.loadtxt(filename), label ) for filename, label in list_of_files]
for data, label in datalist:
pylab.plot( data[:,0], data[:,1], label=label )
print data [:,1]
Temps = [k for k,v in Counter(data[:,1]).items() if v>1 and 1500<=k<2200]
print Temps
print ("Test="), 0.555*(Temps[0]-32)+.651*(Temps[1]-32)