Hi all,
I am using python version 2.3.in a program ,
I have called the sort function.Wherein,
a.sort(reverse=True)
is giving the following error:
TypeError: sort() takes no keyword arguments.
It works in python 2.4,What can be the alternative in python 2.3
Thanks ,
Gaurav 2 2447
gaurav kashyap wrote:
Hi all,
I am using python version 2.3.in a program ,
I have called the sort function.Wherein,
a.sort(reverse=True)
is giving the following error:
TypeError: sort() takes no keyword arguments.
It works in python 2.4,What can be the alternative in python 2.3
Thanks ,
Gaurav
You could try:
>>a.sort() a = a[::-1]
Aidan <aw****@gmail.comwrote:
gaurav kashyap wrote:
>Hi all, I am using python version 2.3.in a program , I have called the sort function.Wherein, a.sort(reverse=True) is giving the following error:
TypeError: sort() takes no keyword arguments.
It works in python 2.4,What can be the alternative in python 2.3
Thanks , Gaurav
You could try:
>a.sort() a = a[::-1]
You could, but you should also be aware that there is a subtle difference.
The 'reverse' keyword argument gives a stable reverse sort, sorting and
then reversing something is not stable. e.g.
>>data = [(1, 'zzz'), (1, 'abc'), (2, 'def'), (1, 'pqr'), (2, 'jkl')] a = data[:] a.sort(lambda p,q: cmp(p[0],q[0]), reverse=True) a
[(2, 'def'), (2, 'jkl'), (1, 'zzz'), (1, 'abc'), (1, 'pqr')]
>>a = data[:] a.sort(lambda p,q: cmp(p[0],q[0])) a[::-1]
[(2, 'jkl'), (2, 'def'), (1, 'pqr'), (1, 'abc'), (1, 'zzz')]
--
Duncan Booth http://kupuguy.blogspot.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul MG |
last post by:
Hi
Is there a simple general way of getting the keys out of a map? Or a vector of
pairs?
My problem seems to be that the pair<> type returned by iterating through either
has no methods to...
|
by: Xah Lee |
last post by:
Sort a List
Xah Lee, 200510
In this page, we show how to sort a list in Python & Perl and also
discuss some math of sort.
To sort a list in Python, use the “sort” method. For example:
...
|
by: winkatl1213 |
last post by:
Hello,
I am working with comtypes to interface Microsoft's DirectShow library.
First, I found a Type Library on the internet that was created for
accessing DirectShow from .NET. It seems that...
|
by: mooon33358 |
last post by:
I have a little problem with implementing a recursive merge sort
I have to use a function mergesort that takes 3 arguments - an array,
its size, and an help array(i.e mergesort(int array, int...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |