Closed timborden closed 1 year ago
To pass a key func, it must be positional else the kwargs are interpreted as a dict which is used for initialization. Read the docs for details
Gotcha...thanks for clarifying
>>> from sortedcontainers import SortedDict
>>> test = SortedDict(lambda x: -x)
>>> test[1] = "foo"
>>> test[3] = "bar"
>>> test
SortedDict(<function <lambda> at 0x1035e2ef0>, {3: 'bar', 1: 'foo'})
(in case someone else is having the same issue)
Trying to reverse sort a SortedDict with an integer key I get a
TypeError: '<' not supported between instances of 'int' and 'str'
error.Is this a bug? ....or am I setting up the key wrong?