473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Tracking sorted items in a zip()ed list

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 ..
so please help me now ..


'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 1392
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 ..
so please help me now ..


'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
'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 ..
so please help me now ..


'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[0] = a,b,r,c
t[1] = a,b,r,c
t[2] = 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[0][0], t[0][1], t[0][3], t[0][2])
I cannot tell what you are trying to do.
Nov 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Daniele Varrazzo | last post by:
If you need a container to look into, there is the sets module that provides a couple of them. If you need a sorted list, there is the bisect module. But i don't think it fits your need for a...
5
by: MackS | last post by:
Dear all, I've got several large sets in my program. After performing several operations on these I wish to present one set to the user sorted according to a certain criterion. Is there any...
10
by: Der Andere | last post by:
I need to implement a sorted (ordered) list. STL has no sorted list type as far as I know. Is there a (straight) way to implement a sorted list using STL? BTW: The type of items in the list will...
4
by: Cybertof | last post by:
Hi ! I would like to make an array of structure (collection ?) that would behave like an advanced sorted list : a sorted list with one key but with multiple values (sorted lists are key/value...
4
by: Olaf Baeyens | last post by:
I have to load about 10000 possible file names into a list and must have thems sorted alphabetically, including the file information. At this moment, in conventional C++, I use a sorted file strng...
2
by: Tom Scales | last post by:
I've got a new problem (making progress on my GetFiles problem). I have a need to keep a large number of entries in a SortedList. My challenge is that there are duplicate entries in the key....
1
by: J L | last post by:
I want to create a sorted list whose values are themselves sorted lists. I wrote the following simple test program but it does not behave as I would expect. What I wanted to do was have the...
4
by: shrishjain | last post by:
Hi All, I need a type where I can store my items in sorted order. And I want to keep adding items to it, and want it to remain sorted. Is there any type in .net which I can make use of. I see...
1
by: Khayrat | last post by:
Hi folks, please help I have a xml file with a list of items. The list is sorted during xslt processing. Based on this sorted list I want a navigation facility to walk through the sorted list...
3
by: Vik Rubenfeld | last post by:
I have to search 2 mySQL tables, and show the user a single sorted list that contains all the results from both mySQL queries. My question is, how do you get all the resulting items from both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.