[issue34016] Bug in sort()

Lucas Sampaio report at bugs.python.org
Sun Jul 1 17:12:21 EDT 2018


Lucas Sampaio <lucassdssampaio at gmail.com> added the comment:

ok, I got it

lista4 = input().split()
print(lista4)
lista4.sort()
print(lista4)

print(type(lista4[2]))

 6 8 10['6', '8', '10']
['10', '6', '8']
<class 'str'>

ok, I got it

2018-07-01 18:05 GMT-03:00 Tim Peters <report at bugs.python.org>:

>
> Tim Peters <tim at python.org> added the comment:
>
> Lucas, as Mark said you're sorting _strings_ here, not sorting integers.
> Please study his reply.  As strings, "10" is less than "9", because "1" is
> less than "9".
>
> >>> "10" < "9"
> True
> >>> 10 < 9
> False
>
> ----------
> nosy: +tim.peters
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue34016>
> _______________________________________
>

----------

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


More information about the Python-bugs-list mailing list