[Python-ideas] `OrderedDict.sort`
Ethan Furman
ethan at stoneleaf.us
Tue Sep 24 16:17:25 CEST 2013
On 09/24/2013 05:27 AM, Ram Rachum wrote:
>
> I think that your mistake is defining OrderedDict as a dict sorting by insertion order. I see no reason to define it
> that way [...]
How would you like it sorted?
- ascending? you can write an algorithm for that
- descending? you can write an algorithm for that
- cyclic? you can write an algorithm for that
- insertion order? you can *not* write an algorithm for that
Insertion order is the one that you either remember, or is lost.
As for a practical example, think of classes that want to know which order their attributes were created in --
OrderedDict to the rescue! :)
--
~Ethan~
More information about the Python-ideas
mailing list