00001 # (IMHO) the simplest approach: 00002 def sortedDictValues(adict): 00003 items = adict.items() 00004 items.sort() 00005 return [value for key, value in items] 00006 00007 # an alternative implementation, which 00008 # happens to run a bit faster for large 00009 # dictionaries on my machine: 00010 def sortedDictValuesFaster(adict): 00011 keys = adict.keys() 00012 keys.sort() 00013 return [adict[key] for key in keys] 00014 00015 # a further slight speed-up on my box 00016 # is to map a bound-method: 00017 def sortedDictValuesFastest(adict): 00018 keys = adict.keys() 00019 keys.sort() 00020 return map(adict.get, keys) 00021
© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."
Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.
122,241 lines of code and growing...