code: def order_columns_in_row(fields, unordered_row):
      
      fields_idx = {f: pos for pos, f in enumerate(fields)}
      return OrderedDict(sorted(unordered_row.items(),
                                key=lambda i: fields_idx[i[0]]))
docs: Ensure columns appear in the same order for every row in table
  
      :param fields:
      :param unordered_row: