title: Django - How to sort a querySet.values() i.e. List of Dictionary?
body: <p>I'm trying to sort a list of dictionary through the use of values() of a querySet.</p>
  
  <p>I find the list of dictionaries through:</p>
  
  <pre><code>set_of_pk_values = user_chartConfigurationData.objects.filter(username_chartNum_id = activeTab+"_"+username).values()
  </code></pre>
  
  <p>Since the data is sent to a jQuery DataTables. The user can click on each of the column to sort the data.</p>
  
  <p>Hence, I find the "key" through order[0][column] from GET</p>
  
  <pre><code>keyOrder = set_of_pk_values[0].keys()[int(order_0_iColumn)]
  </code></pre>
  
  <p>keyOrder is now the key that I want to sort.</p>
  
  <p>However, when I tried to use sorted with a operator:</p>
  
  <pre><code>set_of_pk_values = sorted(set_of_pk_values, key=operator.attrgetter(keyOrder))
  </code></pre>
  
  <p>It returns an error message: 'dict' object has no attribute 'blockName', which is actually one of the attribute of the dictionary, if you would call set_of_pk_values[0]['blockName']</p>