title: python filter and sort list of orderedict from xml2dict
body: <p>i have a question on sorting xml2dict outcome.
  i have a xml like this:</p>
  
  <p>Python 2.7</p>
  
  <pre><code>&lt;schedule&gt;
    &lt;layout file="12" fromdt="2015-07-25 00:42:35" todt="2015-09-02 02:54:14" scheduleid="34" priority="0" dependents="30.jpg,38.mp4,39.mp4"/&gt; 
    &lt;layout file="10" fromdt="2015-08-25 00:42:32" todt="2015-09-02 02:54:03" scheduleid="34" priority="1" dependents="30.jpg,38.mp4,39.mp4"/&gt; 
  &lt;/schedule&gt;
  </code></pre>
  
  <p>in which i use the following code to import to py:</p>
  
  <pre><code>dict_schedule_xml  = xmlFileToDict(filename)
  layoutList.append(dict_schedule_xml['schedule']['layout'])
  </code></pre>
  
  <p>layoutList like below:</p>
  
  <pre><code>[[OrderedDict([(u'@file', u'12'), (u'@fromdt', u'2015-07-24 00:42:35'), (u'@todt', u'2015-09-02 02:54:14'), (u'@scheduleid', u'34'), (u'@priority', u'0'), (u'@dependents', u'30.jpg,38.mp4,39.mp4')]), OrderedDict([(u'@file', u'10'), (u'@fromdt', u'2015-08-25 00:42:32'), (u'@todt', u'2015-09-02 02:54:03'), (u'@scheduleid', u'34'), (u'@priority', u'1'), (u'@dependents', u'30.jpg,38.mp4,39.mp4')])]]
  </code></pre>
  
  <p>and i want to filter out some unwanted entry as execute follow:</p>
  
  <pre><code>dict_filtered_layout_list =  [s for s in layoutList if (onAirSchedule(s['@fromdt'],s['@todt']))]
  dict_filtered_layout_list =  sorted(dict_filtered_layout_list, key=lambda k: k['@priority'], reverse = True)
  </code></pre>
  
  <p>using the following self-defined function:</p>
  
  <pre><code> def onAirSchedule(fromdt, todt):
          dt_now = datetime.now()
          fromdt = datetime.strptime(fromdt,'%Y-%m-%d %H:%M:%S')
          todt   = datetime.strptime(todt,'%Y-%m-%d %H:%M:%S')
          return (fromdt &lt; dt_now &lt; todt) 
  </code></pre>
  
  <p>I wonder everytime i got the error</p>
  
  <pre><code>  File "xibo_reader.py", line 91, in on_modified
      dict_filtered_layout_list =  [s for s in layoutList if (onAirSchedule(s['@fromdt'],s['@todt']))]
  TypeError: list indices must be integers, not str
  </code></pre>
  
  <p>I would like to have help on this as i don't know much on ordereddict behaviour...</p>