Sort the table header in perspective

Hello community
I have a problem and I can’t find the solution
it is the head of a table in perspective I cannot fit them as I want they are ordered according to the data from smallest to largest
my question is is there any way to accommodate the headers?
What I’m doing is from a dataset build a list and for each iteration make an append with 4 data but they don’t fit in the order of the append
does anyone have any suggestions or tips that I can use to accommodate my data

this is part of the code i am using

data = result.getDataset()
		pyData = system.dataset.toPyDataSet(data)
		list1 = []
		for i in range(data.rowCount):
			if data.getValueAt(i,1) != 0:
				list1.append( {'Hora': data.getValueAt(i,0),'Produccion': data.getValueAt(i,1),'Rechazados': data.getValueAt(i,3),'Eficiencia': str(data.getValueAt(i,2))+str(" %")})
		return  list1

the data shown in the table is the following, what I want is that they are ordered in production, rejected and efficiency

Your using a dictionary to store the 4 items of data. Dictionaries do not keep their order.
You could change to using a list instead:

	data = result.getDataset()
	pyData = system.dataset.toPyDataSet(data)
	list1 = []
	for i in range(data.rowCount):
		if data.getValueAt(i,1) != 0:
			list1.append( [data.getValueAt(i,0), data.getValueAt(i,1),data.getValueAt(i,3), str(data.getValueAt(i,2))+str(" %")])
	
	headers = ['Hora', 'Produccion', 'Rechazados', 'Eficiencia']
	ds = system.dataset.toDataSet(headers, list1)

thank you very much if it worked