title: Is python's sorted() function guaranteed to be stable?
body: <p>The <a href="http://docs.python.org/library/functions.html#sorted" rel="noreferrer">documentation</a> doesn't guarantee that. Is there any other place that it is documented? </p>
  
  <p>I'm guessing it might be stable since the sort method on lists is <a href="http://docs.python.org/library/stdtypes.html#mutable-sequence-types" rel="noreferrer">guaranteed to be stable</a> (Notes 9th point: "Starting with Python 2.3, the sort() method is guaranteed to be stable"), and sorted is functionally similar. However, I'm not able to find any definitive source that says so. </p>
  
  <p>Purpose: I need to sort based on a primary key and also a secondary key in cases where the primary key is equal in both records. If sorted() is guaranteed to be stable, I can sort on the secondary key, then sort on the primary key and get the result I need. </p>
  
  <p>PS: To avoid any confusion, I'm using stable in the sense of "a sort is stable if it guarantees not to change the relative order of elements that compare equal".</p>