title: 'int' object is not subscriptable in lambda python
body: <p>I have created a list of dict which I want to sort according to one element (Period) in the dict</p>
  
  <pre><code>T=dict()
  def TaskGenerator(N):
      for i in range (0,N):
          ExcTime=randint(1,20)
          Period=randint(1,20)+ExcTime
          Uterlization=ExcTime/Period
          T[i]={'ID':i+1 , 'ExcTime' : ExcTime, 'Period' : Period, 'Uterlization':Uterlization}
      sorted(T,key=lambda x:x['Period'])
  TaskGenerator(6)
  </code></pre>
  
  <p>However, It gives me an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\wei.du\Desktop\real-time\RMLS.py", line 33, in &lt;module&gt;
      TaskGenerator(6)
    File "C:\Users\wei.du\Desktop\real-time\RMLS.py", line 17, in TaskGenerator
  sorted(T,key=lambda x:x['Period'])
    File "C:\Users\wei.du\Desktop\real-time\RMLS.py", line 17, in &lt;lambda&gt;
  sorted(T,key=lambda x:x['Period'])
  TypeError: 'int' object is not subscriptable
  </code></pre>
  
  <p>I think it means that in "sorted" function, in lambda function, "x" is an integer. But I do not really understand, isn't "x" an instant of T[i] (eg.T[1], which is of a dict type in python). why it complaints about "x" being an integer?</p>