> Yikes! Alan must have been up too late. They are not the same at
all.
> Alan's code creates a list containing *every combination* of one
> element from each source list:
Oops! Blush...
Lack of testing I'm afraid, I checked the syntax worked but not
the actual results! Thing is, I knew about zip
Max Noel wrote:
On Apr 1, 2005, at 09:59, Alan Gauld wrote:
Since the data are obviously related (since you need to keep them
linked),
I'd be inclined to merge the lists into a list of tuples
merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4]
Then you can sort 'merged' and it shou
On Apr 1, 2005, at 09:59, Alan Gauld wrote:
Since the data are obviously related (since you need to keep them
linked),
I'd be inclined to merge the lists into a list of tuples
merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4]
Then you can sort 'merged' and it should just work
> I need to sort 4 lists but I need that they make the "sort
together".
> I'll sort just one but when I change the position of the items of
the
> 1st list I have to change the positions of the other 3 lists. Can I
do
> this just using the sort() method of the list object?
> If I can't, someone know
> What's b.index(x) do?
>
> I'm guessing the for a list Delta = ["a,"b","c"], you get
>
> Delta.index("b")
>
> 1
>
> Am I right?
Yes. For future use, the easiest way to answer a question like that is to
do:
>>> help([].index)
Help on built-in function index:
index(...)
L.index(value,
What's b.index(x) do?
I'm guessing the for a list Delta = ["a,"b","c"], you get
Delta.index("b")
1
Am I right?
On Apr 1, 2005 1:16 PM, py <[EMAIL PROTECTED]> wrote:
>
>
> An alternative way of doing this (if you have python 2.4):
>
> >>> ppl = ['john', 'mary', 'lary', 'jane']
> >>> age
An alternative way of doing this (if you have python 2.4):
>>> ppl = ['john', 'mary', 'lary', 'jane']>>> age = [15, 30, 23, 25]>>> height= [160, 165, 178, 170]>>> sortby = lambda a, b: [a[b.index(x)] for x in sorted(b)]>>> sortby(ppl, age)['john', 'lary', 'jane', 'mary']>>> sortby(ppl, height)[
Diego Galho Prestes wrote:
Hi!
I need to sort 4 lists but I need that they make the "sort together".
I'll sort just one but when I change the position of the items of the
1st list I have to change the positions of the other 3 lists. Can I do
this just using the sort() method of the list object?
You
On Mar 31, 2005, at 04:19, Diego Galho Prestes wrote:
Hi!
I need to sort 4 lists but I need that they make the "sort together".
I'll sort just one but when I change the position of the items of the
1st list I have to change the positions of the other 3 lists. Can I do
this just using the sort() met
Brian van den Broek said unto the world upon 2005-03-30 18:28:
Diego Galho Prestes said unto the world upon 2005-03-30 21:19:
Hi!
I need to sort 4 lists but I need that they make the "sort together".
I'll sort just one but when I change the position of the items of the
1st list I have to change the
Diego Galho Prestes said unto the world upon 2005-03-30 21:19:
Hi!
I need to sort 4 lists but I need that they make the "sort together".
I'll sort just one but when I change the position of the items of the
1st list I have to change the positions of the other 3 lists. Can I do
this just using the s
Hi!
I need to sort 4 lists but I need that they make the "sort together".
I'll sort just one but when I change the position of the items of the
1st list I have to change the positions of the other 3 lists. Can I do
this just using the sort() method of the list object?
If I can't, someone know a si
12 matches
Mail list logo