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