If you want to sort your user list by data size, then you should first create a list of tuples [(size, user), ...] instead of directly formatted it into a joined string. You can sort the list and then join it into a string. Its not really a matter of "linking" dictionaries, since you are currently getting the data you want, just not in the sort order you want.
Eventually if you find yourself creating tons of dictionaries and trying to correlate them together into data sets, it sounds like you are in need of a database, be it in-memory or file based. Something like in-memory sqlite or the pandas data framework (which I haven't used but recall being something suited for this). Justin On Wed, Feb 15, 2017 at 2:06 PM likage <[email protected]> wrote: > Thank you Justin for your help. > My bad, it does seems I have omitted out a portion of where/how gen_dict > comes about but in any case, it comes from an iterator. And since I am only > getting 2 parameters - namely the object name and the user name affiliated > with it, I made it into a dictionary, as this is the best solution I can > come up with. > > Even so, if this time round I had wanted to add in an additional > parameter, say the size of each item such that it is (this is not a dict > yet): > (1 MiB) "item_C_v001" : "jack" > (5 MiB) "item_C_v002" : "kris" > (1 MiB) "item_A_v003" : "john", > (1 MiB) "item_B_v006" : "peter", > (2 MiB) "item_A_v005" : "john", > (1 MiB) "item_A_v004" : "dave" > > While I am able to make my output as follows: > Item Name | No. of Vers. | User > > item_A | 3 | dave(1, 1MiB), john(2, 3MiB) > item_B | 1 | peter(1, 1MiB) > item_C | 2 | jack(1, 1MiB), kris(1, 5MiB) > > My code is as follows: http://pastebin.com/G8WVzE3e > > Wondering if you could take a look and see if my method is a good way of > doing so? > I am having some difficulties of seeing how I can get the dictionaries I > have created to 'link' / make use of each other, because say if I am trying > to sort it by data size in descending order, it is not working even if I > try to sort it by the values.. > Pardon me if my code is not fanciful > > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/557625a8-3f4f-412f-aced-e16ce966d37d%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/557625a8-3f4f-412f-aced-e16ce966d37d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30k%3Dd5Dq9crjf2FQYD3FgeGdTZ2EV%3D9kiCGU2yTBdw%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
