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 -
a = [3, 2, 1]
-
b = [7, 5, 3]
-
c = [56, 242, 4]
-
r = [31, 146, 124]
-
-
t = zip(a, b, c, r)
-
print t
-
# [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
-
for i, intTuple in enumerate(t):
-
t[i] = sorted(intTuple)
-
print t
-
# [[3, 7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
-
-
print t[:1]
-
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
3 1411 bvdet 2,851
Recognized Expert Moderator Specialist
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 -
a = [3, 2, 1]
-
b = [7, 5, 3]
-
c = [56, 242, 4]
-
r = [31, 146, 124]
-
-
t = zip(a, b, c, r)
-
print t
-
# [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
-
for i, intTuple in enumerate(t):
-
t[i] = sorted(intTuple)
-
print t
-
# [[3, 7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
-
-
print t[:1]
-
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'?
'm sorry what i meant was the array names ... a b r c
bvdet 2,851
Recognized Expert Moderator Specialist
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 -
a = [3, 2, 1]
-
b = [7, 5, 3]
-
c = [56, 242, 4]
-
r = [31, 146, 124]
-
-
t = zip(a, b, c, r)
-
print t
-
# [(31, 7, 56, 3), (2, 5, 242, 146), (1, 3, 4, 124)]
-
for i, intTuple in enumerate(t):
-
t[i] = sorted(intTuple)
-
print t
-
# [[3, 7, 31,56], [2, 5, 146, 242], [1, 3, 4, 124]]
-
-
print t[:1]
-
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: - 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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 quick lookup: it's a python module so probably it's
slower. Furthermore you can __hash__ almost everything, but you can __cmp__
in a consistent way much less stuff.
Take definitely a look at sets.
|
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 direct way to do
so? Or must I
list =
for item in set1:
|
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 be a class. Is it necessary to
implement the > or < operators or to write a compare-function that returns
the larger or smaller of two classes? Ideally, the list begins with the
smallest element.
Cheers,
Matthias
|
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 items).
- indexed by value index or by key (2 indexers)
- sortable by key or a secondary key
- supporting foreach loops
|
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 list with a
binary search to add the file name at the correct location, this way it is
very fast. I but I created my own string list.
So here is my question: Does C# or the .NET framework have such a sorted
list that I can add the items during...
| |
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. That's OK for my
application, but not for a Sorted list.
Any thoughts?
Thanks,
|
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 doorConflictList be keyed on a door
ID and contain a sorted list called conFlictList. I wrote this
expecting the following
doorConflictList should end up with 3 items.
Item 1 would be a sorted list with 1 item
|
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 there is SortedList<key, value> for hash tables, but could find
anything for a sorted list.
Currently I am using List<string> and whenever I add an item, I need to
|
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 starting from a choosen item via <back> and
<next>.
Say this is the list:
<a>
|
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
databases into one single, sorted list, to present to the user?
I guess one way would be, to use PHP to copy all the results from each
database, into a PHP array, and then sort it. Is that how this kind of
thing is usually done?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |