lists - append - unique and sorted

Neil Cerutti horpner at yahoo.com
Wed Jun 6 19:13:35 CEST 2007


On 2007-06-06, Josiah Carlson <josiah.carlson at sbcglobal.net> wrote:
> Neil Cerutti wrote:
>> On 2007-06-06, rhXX <rh00667 at gmail.com> wrote:
>>> and/or
>>>
>>> - SORTED - INSERT in the correct place using some criteria?
>> 
>> Consult the Python Docs about the heapq module.
>
> Heaps (as produced by heapq) are not sorted.  This will not
> produce correct results unless one then pops everything and
> de-dupes the output.

i agree that using bisect and inserting manually clearly meets
the stated requirements, while there isn't enough information to
know if a heapq will meet his requirements.

Thanks for the correction.

-- 
Neil Cerutti
In my prime I could have handled Michael Jordan.  Of course, he would be only
12 years old. --Jerry Sloan



More information about the Python-list mailing list