RE: Sorted List

From: Delaney, Timothy C (Timothy) (tdelaney_at_avaya.com)
Date: 07/27/04


Date: Tue, 27 Jul 2004 10:01:23 +1000
To: <python-list@python.org>

Dan wrote:

> I like the sets type in python 2.4 but it has one major limitation,
> it is an unordered collection.
>
> I needed a container more like a list, but sorted so that searches
> are fast and ensure elements are in a specifc order. This is very
> useful for 'fuzzy logic' type searching. I could not find any
> container in Python that fits this criteria, nor could I find one in
> the vault so I created SortedList.

Check the 'heapq' standard library module.

> What should I do with it when I'm done? Is there a place for
> Pythoniers to share code?

Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/

Tim Delaney



Relevant Pages

  • Re: Interface of the set classes
    ... >>I don't know why this is different in Python! ... between S and V which is "storing values in a linear container". ... >>this interface incompatible with lists. ... That was all the methods I imagined for Python's genericity. ...
    (comp.lang.python)
  • Re: Default method arguments
    ... > I'm not very familiar with Python, so please explain me why should ... the function bar binds the name s in the function bar, ... with mutating an object bound to a name in an outer scope. ... the container is named foo and is an object ...
    (comp.lang.python)
  • R: Sorted list as an alternative to dictionary for when you only needkeys?
    ... If you need a container to look into, there is the sets module that provides ... with fast lookup by value. ... Better would be a python list that is sorted ... write a wrapper class for list that does this, but is there maybe not such a ...
    (comp.lang.python)
  • Re: Endless Oil?
    ... the gases will still be ... >>Best, Dan. ... And because the velocity of the molecules ... Consider just one molecule in the container. ...
    (sci.energy.hydrogen)
  • Re: Endless Oil?
    ... the gases will still be ... >>Best, Dan. ... And because the velocity of the molecules ... Consider just one molecule in the container. ...
    (sci.energy)