Sorted dataframe resets after indexing
I found a in issue when sorting followed by indexing in pandas when reset_index() is not used. I'm not sure why but the ordering of the rows reverts back after indexing and hence results in dfList containing dataframes that are ordered differently. 

reset_index() works and helped to overcome the problem. This is really subtle and rather difficult to troubleshoot. I hope this would be useful for others. 

currentReadFile = pd.read_table(currentFile)
matrix = currentReadFile.sort(['Ref','Var','Before','After'])
matrix_out = matrix.ix[:,4:]
dfList.append(matrix_out)
