Dear All,
I am new to Python. I am in need of
some sorting functions (eg) numerical sorting
functions and alphapetical sorting functions.
I have searched through net But I cannot
find any regarding this so If anyone know
regarding this. Kindly mail me as early as possible
with regards
PRabahr
_______________ _______________ _______________ _______________ ____________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony 3 1774
On Mon, 11 Apr 2005 05:50:11 +0100 (BST), praba kar <pr*********@ya hoo.co.in> wrote: Dear All,
I am new to Python. I am in need of some sorting functions (eg) numerical sorting functions and alphapetical sorting functions. I have searched through net But I cannot find any regarding this so If anyone know regarding this. Kindly mail me as early as possible
with regards PRabahr
Frankly, your claim to has "searched through the net" is not believable,
unless you are not using a search engine such as google, in which case
go to google.com (assuming you know how to do that) and type in something
like
sorting site:python.org
and press enter. The "site:python.or g" will limit the search to
what is available on the python.org site, which has a high concentration
of Python-relevant information.
Perhaps this will help someone avoid a seemingly helpless or lazy post like yours.
BTW, a request to "mail me as early as possible" is more likely
to get favorable consideration if you explain why you can't
monitor the newsgroup postings for a reply.
Regards,
Bengt Richter
Basically you can sort after you put your data in your list:
L = [1.2,1.23,4.5,2]
L.sort()
print L
L = ["a","c","b","A" ,"C","B"]
L.sort()
print L
Result:
[1.2, 1.23, 2, 4.5]
['A', 'B', 'C', 'a', 'b', 'c']
#------------------------------------------------------------
remember in character the "A" has lower ascii value then "a"
To model this as a function you just need this code for two of them:
def funcSort(myList ):
result = myList[:]
result.sort()
return result
Use of this function:
L = [1.2,1.23,4.5,2]
res1 = funcSort(L)
print res1
L = ["a","c","b","A" ,"C","B"]
res1 = funcSort(L)
print res1
Best Regards,
Pujo aj****@gmail.co m wrote: def funcSort(myList ): result = myList[:] result.sort() return result
In Python 2.4, funcSort is called sorted:
py> sorted([1.2,1.23,4.5,2])
[1.2, 1.23, 2, 4.5]
py> sorted(["a","c","b","A" ,"C","B"])
['A', 'B', 'C', 'a', 'b', 'c']
STeVe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: praba kar |
last post by:
Dear All,
I have doubt regarding sorting. I have a list
that list have another list (eg)
list = ,,]
I want to sort only numeric value having array field.
How I need to do for that.
|
by: Karin Jensen |
last post by:
Hi
I am running a PHP program that connects to an Access 2000 database
via ODBC:
$results = odbc_exec($connection_id, $sql_select);
Is it possible to sort the contents of $results? I wish to use a
regex-based sort order that you can't do in Access 2000* SQL with
"ORDER BY".
|
by: Mike |
last post by:
Hello,
I have a few rather urgent questions that I hope someone can help with (I
need to figure this out prior to a meeting tomorrow.) First, a bit of
background: The company I work for is developing a web-based application,
one part of which involves allowing the user the ability to page through
transaction "history" information.
The _summary_ history table will have the following fields: ServiceName,
Date, User-Ref1, User-Ref2,...
|
by: edu.mvk |
last post by:
Can we use the slots in QCopchannel as ordinary member functions ??
that means in QT we have to connect the SLOTs to SIGNALS and that will
be invoked if the signal is happend
is it possible for me to call a slot from any other member function of
the same class just like ordinary member functions...??
Thanks.
|
by: edu.mvk |
last post by:
Hi
I am using strcpy() in my code for copying a string to another string.
i am using static char arrays.
for the first time it is exected correctly but the second time the
control reaches then the SEGMENTATION FAULT is occuring.
Please tell me what are all the cases this problem may occur if we use
strcpy().
| |
by: ivan |
last post by:
hi all,
if I have:
if(A && B || C)
which operation gets executed first?
If I remeber well should be &&, am I correct?
thanks
|
by: Anarki |
last post by:
##include <iostream>
using namespace std;
class A
{
};
class B:virtual public A
{
};
class C:virtual public A
|
by: KevinADC |
last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
|
by: Bob Laubla |
last post by:
Hello
I have a very complex maketable query with many records and involving multiple VB functions which call other functions.
I need this table to be sorted by the first field.
But no matter what I do, there is a small chance of the table coming out unsorted.
I have tried sorting it with the 'make table' query.
I have tried sorting it with Word during output (my current configuration runs 4 of these).
I have tried reading it into an...
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |