On Fri, Nov 29, 2013 at 12:54 PM, iMath <redstone-c...@163.com> wrote: > the container is similar to queue ,but queue doesn't have a sort function
It's either a queue that can be sorted, or a list with a length limit. You could fairly easily implement either, because in Python, anything can be subclassed. But I think possibly the easiest way is to simply turn your queue into a list when you want to work with it: >>> import queue >>> a=queue.Queue(10) >>> a.put("asdf") >>> a.put("qwer") >>> a.put("zxcv") >>> a.put("1234") >>> sorted(a.queue) ['1234', 'asdf', 'qwer', 'zxcv'] Though I don't know if this is what you meant. Putting too much onto a queue.Queue will block. Were you wanting it, instead, to discard entries? If so, which? ChrisA -- https://mail.python.org/mailman/listinfo/python-list