473,385 Members | 1,486 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,385 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 1391
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.