Python - order dictionary data
Question: My knowledge about Python is really low. I am trying to order data from a
dictionary and I do not know how. I have tried OrderedDict, Sort and
variable.sorted but I only got errors.

What I have tried:

    
    
    textos_informativos = []
    for t in c.producto.textos:
        textos_informativos.append(dict(orden=t.orden,
                                        tipo=t.tipo.nombre,
                                        informacion=t.informacion))
    

I would like to order the data based on "t.orden" data (int).


Answer: Thanks,

I've tryied:

    
    
    from collections import OrderedDict        
    
    textos_informativos = []
        for t in c.producto.textos:
           textos_informativos.append(OrderedDict(orden=t.orden,
                                           tipo=t.tipo.nombre,
                                           informacion=t.informacion))
    

Nothing happened.

* * *
    
    
    textos_informativos = []
      for t in c.producto.textos:
           textos_informativos.append(dict(orden=t.orden,
                                           tipo=t.tipo.nombre,
                                           informacion=t.informacion))
      sorted (textos_informativos, key= t.orden)
    

Error 'int' object is not callable

* * *
    
    
    textos_informativos = []
      for t in c.producto.textos:
           textos_informativos.append(dict(orden=t.orden,
                                           tipo=t.tipo.nombre,
                                           informacion=t.informacion))
      t.orden.sort()
    

Error 'int' object has no attribute 'sort'

* * *

