title: Is there a way to sort a list in python until the first sorted k elements are found?
body: <p>I have a normal boring list of non sorted numbers. From that list I need to take the first k elements after sorting. The thing is that if the list is considerably long and k is considerably small sorting the entire list seems like a waste. I came up with an algorithmic solution for this, but requires me to write my own implementation for sorting, my question is: is there a way to get the same efficiency using something already implemented in python?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Just to clarify, I know this will give the answer I need: <code>sorted(boring_list)[:n]</code></p>
  
  <p>But my concern is efficiency: <strong>I don't need to sort the whole list for this.</strong> </p>