[New-bugs-announce] [issue40081] List sorting

Sivasundar Nagarajan report at bugs.python.org
Thu Mar 26 22:26:02 EDT 2020


New submission from Sivasundar Nagarajan <sivasundar.nagarajan at in.ibm.com>:

Good day. Hope you are safe and wish the same with the present situation.
Need you help please in understanding the below function of Python. 
 
 
Steps - 
1. tried assigning the below values in the list and named it as a
2.if I print, it prints in the same sequence.
3.Tried assigning it to b by the command a.sort()
4.Tried printing b and it gave null.
5.But printed a now, and the values were sorted.
 
 
Please help me understand if we have any logic with in a list to sort the values after an iteration.
Please apologize if I had missed some basics and uncovered it. 
 
>>> a = [1,4,3,2,4,5,3,2]
>>> a
[1, 4, 3, 2, 4, 5, 3, 2]
>>> print (a)
[1, 4, 3, 2, 4, 5, 3, 2]
>>> b = a.sort()
>>> b
>>> print (a)
[1, 2, 2, 3, 3, 4, 4, 5]
>>>

----------
assignee: terry.reedy
components: IDLE
messages: 365129
nosy: Sivasundar Nagarajan, terry.reedy
priority: normal
severity: normal
status: open
title: List sorting
type: resource usage
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40081>
_______________________________________


More information about the New-bugs-announce mailing list