Python Sort Method Algorithm And Problem