Sort can do that
In [2]: list01=['cleve', 'adam', 'yuno', 'pete'] In [3]: list02 = ['pete', 'yuno', 'cleve', 'adam'] In [4]: list02 = sorted(list2, key=list01.index) In [5]: list02 Out[5]: ['cleve', 'adam', 'yuno', 'pete'] On Wed, Oct 10, 2018 at 2:31 PM kiteh <[email protected]> wrote: > Hi Justin, sorry that I may have made my question confusing/ I was > babbling, typing away of the way I am trying to phrase my question. > Let me try again :) > > 1. Deriving the hierarchy from Outliner > Eg. This is the hierarchical level as seen in my Outliner > > |-- base > |--|-- names > |--|--|-- cleve > |--|--|-- adam > |--|--|-- yuno > |--|--|-- pete > > > If I run a cmds command as follows, note that the result is as what I will > be seeing in the Outliner. > > list01 = cmds.listRelatives('base', ad=True, f=True)[:-1] > print all_items > """ > Result : > ['|base|name|cleve', > '|base|name|adam', > '|base|name|yuno', > '|base|name|pete'] > """ > > > 2. As mentioned, list02 is derived from dictionary keys from a custom > module, but the result/ order from the dictionary's keys does not follows > any orders etc. > list02 = ['pete', 'yuno', 'cleve', 'adam'] > > > And so, I am trying to check the ordering between 2 lists, one from > Outliner, the other from a custom iterator, where list01 is the main list > to be check. > In this case, what I am trying to achieve is: > > - if the order of list02 is different from list01, re-order the items > in list02 such that it follows the same hierarchical level in list01 > > > About the part that I say I cannot use `list01 = list02` is because I will > be making use of the other values within that dicitonary (where it derive > the list02) in a different application, and sorry that I mentioned about > `sorted`, ignore it as I seems to have make the question more confusing. > > -- > 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/d6c9066b-e3f2-4186-b544-98bea96b5726%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/d6c9066b-e3f2-4186-b544-98bea96b5726%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- --:: Kurian ::-- -- 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/CANEMyhM3UEYTevSG97UrekfCkAW26Yac10Ut3vhjkLmmaWh-JA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
