title: python tkinter treeview sort tree
body: <p>based on examples and Henry's help I have come up with the following code to sort the tree in a tkinter treeview, but it does not work.
  I do not get any errors but the tree is not sorted.
  Any help is appreciated.</p>
  
  <pre><code>def treeview_sort_column(tv, col, reverse):
      l = [(tv.set(k, col), k) for k in tv.get_children('')]
      l.sort(key=lambda t: int(t[0]), reverse=reverse)
      #      ^^^^^^^^^^^^^^^^^^^^^^^
  
      for index, (val, k) in enumerate(l):
          tv.move(k, '', index)
  
      tv.heading(col,
                 command=lambda: treeview_sort_column(tv, col, not reverse))
  
  
  def SortTree():
  
      columns = ('#0',)
  
      for col in columns:
          tree.heading(col, text=col,
                           command=lambda c=col: treeview_sort_column(tree, c, False))
  </code></pre>