473,320 Members | 2,029 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,320 software developers and data experts.

Why there isn't a sort method for array ?

Hi,

It seems that an array acts like an list very much, except it doesn't
have a method sort.
Regards,

Dec 17 '06 #1
3 1297
"fd********@gmail.com" <fd********@gmail.comwrote:
>
It seems that an array acts like an list very much, except it doesn't
have a method sort.
What do you mean by "array"? There is no such beast in the Python
language. Do you mean the library module "array"?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 17 '06 #2

Tim Roberts wrote:
"fd********@gmail.com" <fd********@gmail.comwrote:

It seems that an array acts like an list very much, except it doesn't
have a method sort.

What do you mean by "array"? There is no such beast in the Python
language. Do you mean the library module "array"?
Indubitably the OP means objects created by the array function in the
array module. Does that help you answer his question?

Cheers,
John

Dec 18 '06 #3
John Machin wrote:
Tim Roberts wrote:
>"fd********@gmail.com" <fd********@gmail.comwrote:
>>It seems that an array acts like an list very much, except it doesn't
have a method sort.
What do you mean by "array"? There is no such beast in the Python
language. Do you mean the library module "array"?

Indubitably the OP means objects created by the array function in the
array module. Does that help you answer his question?

Cheers,
John
Yep. Seems like there should be a sort() for array.array objects,
especially since they implement pop(), insert(), extend(), etc. Also,
all data types corresponding to array typecodes can be compared in a
sort: <http://docs.python.org/lib/module-array.html>.

In the mean time, try

my_sorted_array = array.array(my_array.typecode, sorted(my_array))

James
Dec 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rene \(Programmer Wannabe\) | last post by:
Sorry for reposting this question, I asked this a couple of days ago but got no definite answer as to why the Array class behaves this way. Hope this time I will have better luck. Please read...
7
by: Daniel | last post by:
does C# have any collection objects that support sort functionality so that I dont have to write my own sorting algorithm?
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
16
by: Gerrit | last post by:
Hello, Is it possible to sort an array with a struct in it? example: I have a struct: public struct mp3file { public int tracknr;
5
by: Jan Smith | last post by:
I've searched the overloads for the Array.Sort method, and I haven't found a clear answer to my question. Maybe it's not in Array.Sort. Here's the question: I initialize an array X with the...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
0
by: JosAH | last post by:
Greetings, I was asked to write a Tip Of the Week; so here goes: a lot of topics are started here in this forum (and a lot of other forums too) mentioning a problem about sorting data. ...
4
by: artev | last post by:
if I have one simple array 1 4 2 6 for to order the code is: arrayOrdin=arraySimple.sort(); and I have 1
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.