title: How to keep a sorted list while entering data into it in Python
body: <p>I have a list of lists which need to be sorted based on the length of the lists. What I am doing now is first inserting the lists into the main list and then sort the main list giving <code>key=len</code>. This steps will take a total time of <code>n + nlg(n)</code>. Is it possible to maintain a sorted list while entering the data into the main list? Can it be done using bisect (or is there any better way) and if so will it perform better than<code>n + nlg(n)</code>? </p>