Re: [Maya-Python] Sort a list using another list

2016-08-17 Thread Justin Israel
On Thu, Aug 18, 2016 at 4:51 PM Christopher Crouzet < christopher.crou...@gmail.com> wrote: > Aren asked for “any number of resulting lists”, which I interpreted as him > wanting one list of UVs per shell, whereas the sorted zip version returns a > single list of ordered UVs with no way to figure

Re: [Maya-Python] Sort a list using another list

2016-08-17 Thread Christopher Crouzet
Aren asked for “any number of resulting lists”, which I interpreted as him wanting one list of UVs per shell, whereas the sorted zip version returns a single list of ordered UVs with no way to figure out from which shell they belong to. But that wouldn't be the first time that I misunderstand somet

Re: [Maya-Python] Sort a list using another list

2016-08-17 Thread Justin Israel
On Thu, Aug 18, 2016 at 4:40 PM Justin Israel wrote: > On Thu, Aug 18, 2016 at 4:34 PM Christopher Crouzet < > christopher.crou...@gmail.com> wrote: > >> If I'm understanding it right, try this: >> >> import itertools >> >> def sort_uvs_by_shells(uvs, shells): >> groups = itertools.groupby(so

Re: [Maya-Python] Sort a list using another list

2016-08-17 Thread Justin Israel
On Thu, Aug 18, 2016 at 4:34 PM Christopher Crouzet < christopher.crou...@gmail.com> wrote: > If I'm understanding it right, try this: > > import itertools > > def sort_uvs_by_shells(uvs, shells): > groups = itertools.groupby(sorted(zip(shells, uvs)), key=lambda x: > x[0]) > return ((group

Re: [Maya-Python] Sort a list using another list

2016-08-17 Thread Christopher Crouzet
If I'm understanding it right, try this: import itertools def sort_uvs_by_shells(uvs, shells): groups = itertools.groupby(sorted(zip(shells, uvs)), key=lambda x: x[0]) return ((group[0], [x[1] for x in group[1]]) for group in groups) # dictionary version: # return {group[0]: [x[1]

[Maya-Python] Sort a list using another list

2016-08-17 Thread Aren Voorhees
I realized that subject doesn't sound like it makes any sense - but here is what I'm trying to do: I am generating two lists...one looks something like this - [MeshUV(u'pCubeShape1.map[0]'), MeshUV(u'pCubeShape1.map[1]'), MeshUV(u'pCubeShape1.map[2]'), MeshUV(u'pCubeShape1.map[3]'), MeshUV(u'