471,338 Members | 1,295 Online

# Tracking sorted items in a zip()ed list 9
firstly i want to thatn all you guys for the help on the sorting program

i have a problem that i tried but 'm unable to solve ...

u guys helped a lot in my previous post ..

'm using windows

heres my code

Expand|Select|Wrap|Line Numbers
1. a = [3, 2, 1]
2. b = [7, 5, 3]
3. c = [56, 242, 4]
4. r = [31, 146, 124]
5.
6. t = zip(a, b, c, r)
7. print t
8. # [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
9. for i, intTuple in enumerate(t):
10.     t[i] = sorted(intTuple)
11. print t
12. # [[3,  7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
13.
14. print t[:1]
15.
now if i print t[:1]

the output will be
[3,7,31,56]

my problem is ... how can i print the a,b,c,d for the coresponding vectors

i.e

i want to print for the above axample ... [3,7,31,56 ] - [a,b,r,c]

and also print
a
b
c
d
Nov 26 '07 #1
3 1196 bvdet
2,851 Expert Mod 2GB
firstly i want to thatn all you guys for the help on the sorting program

i have a problem that i tried but 'm unable to solve ...

u guys helped a lot in my previous post ..

'm using windows

heres my code

Expand|Select|Wrap|Line Numbers
1. a = [3, 2, 1]
2. b = [7, 5, 3]
3. c = [56, 242, 4]
4. r = [31, 146, 124]
5.
6. t = zip(a, b, c, r)
7. print t
8. # [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
9. for i, intTuple in enumerate(t):
10.     t[i] = sorted(intTuple)
11. print t
12. # [[3,  7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
13.
14. print t[:1]
15.
now if i print t[:1]

the output will be
[3,7,31,56]

my problem is ... how can i print the a,b,c,d for the corresponding vectors

i.e

i want to print for the above example ... [3,7,31,56 ] - [a,b,r,c]

and also print
a
b
c
d
Can you provide us with the definition of 'd'?
Nov 26 '07 #2
ashishbathini
9 'm sorry what i meant was the array names ... a b r c
Nov 27 '07 #3
bvdet
2,851 Expert Mod 2GB
firstly i want to thatn all you guys for the help on the sorting program

i have a problem that i tried but 'm unable to solve ...

u guys helped a lot in my previous post ..

'm using windows

heres my code

Expand|Select|Wrap|Line Numbers
1. a = [3, 2, 1]
2. b = [7, 5, 3]
3. c = [56, 242, 4]
4. r = [31, 146, 124]
5.
6. t = zip(a, b, c, r)
7. print t
8. # [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
9. for i, intTuple in enumerate(t):
10.     t[i] = sorted(intTuple)
11. print t
12. # [[3,  7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
13.
14. print t[:1]
15.
now if i print t[:1]

the output will be
[3,7,31,56]

my problem is ... how can i print the a,b,c,d for the coresponding vectors

i.e

i want to print for the above axample ... [3,7,31,56 ] - [a,b,r,c]

and also print
a
b
c
d
When you sort each list, they no longer correspond to a,b,c,r. In your example:
t = a,b,r,c
t = a,b,r,c
t = a,b,c,r

To print a,b,c,r for the first item in the list:
Expand|Select|Wrap|Line Numbers
1. print 'a = %d\nb = %d\nc = %d\nr = %d' % (t, t, t, t)
I cannot tell what you are trying to do.
Nov 27 '07 #4