title: Python 2.7 sort function that sets a sequence number property
body: <p>I want to be able to sort a list of objects (let's say dictionaries for now), but instead of re-arranging their locations in a list, I'd like to set a property on each one to an integer value that represents it's place in the sequence. </p>
  
  <p>For example, suppose I have a list like this:</p>
  
  <pre><code>mylist = [
    {
      'date': '2018-07-02',
      'sequence': null
    },
  
    {
      'date': '2015-01-03',
      'sequence': null
    },
    {
      'date': '2017-05-12',
      'sequence': null
    },
    ...
  ]
  </code></pre>
  
  <p>I'd like to have a function that looks like:</p>
  
  <pre><code>assign_sequence(my_list, key='date', sequence_property='sequence')
  </code></pre>
  
  <p>And have it output:</p>
  
  <pre><code>[
    {
      'date': '2018-07-02',
      'sequence': 3
    },    
    {
      'date': '2015-01-03',
      'sequence': 1
    },
    {
      'date': '2017-05-12',
      'sequence': 2
    },
    ...
  ]
  </code></pre>
  
  <p>The reason is that the data is ultimately for a legacy system that expects the sequence number and can't work without it. </p>
  
  <p>Of course I can just sort them in the traditional way, and then iterate over them again with enumerate() and assign the index. But I was just wondering if there's a more efficient or more elegant way. </p>