code: def sort_diclist(undecorated, sort_on):
      
      decorated = [(len(dict_[sort_on]) if hasattr(dict_[sort_on], '__len__') else dict_[
                    sort_on], index) for (index, dict_) in enumerate(undecorated)]
      decorated.sort()
      return[undecorated[index] for (key, index) in decorated]
docs: Sort a list of dictionaries by the value in each
      dictionary for the sorting key
  
      Parameters
      ----------
      undecorated : list of dicts
      sort_on : str, numeric
          key that is present in all dicts to sort on
  
      Returns
      ---------
      ordered list of dicts
  
      Examples
      ---------
      >>> lst = [{'key1': 10, 'key2': 2}, {'key1': 1, 'key2': 20}]
      >>> sort_diclist(lst, 'key1')
      [{'key2': 20, 'key1': 1}, {'key2': 2, 'key1': 10}]
      >>> sort_diclist(lst, 'key2')
      [{'key2': 2, 'key1': 10}, {'key2': 20, 'key1': 1}]