If I have a dictionary in Python, where the keys are strings, and the
values are instances of a class of mine, how can I get the list of keys
sorted based on a property on my class? I can obviously do this
manually, but was wondering if there was an inbuilt Python way of doing
it more easily. As an example:
Class MyClass:
def __init__(self, prop)
self.prop = prop
def main():
test=dict()
test["a"] = MyClass(46)
test["b"] = MyClass(3)
test["c"] = MyClass(15)
# I would like to generate
sortedTest=list()
#containing b, c, a in that order.
Thanks,
Leo
--
Please post to: Hampshire@???
Web Interface:
https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL:
http://www.hantslug.org.uk
--------------------------------------------------------------