This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python Fuction min is case sentive ?
Type: behavior Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: tim.peters, uppalanchupavankumar45@gmail.com
Priority: normal Keywords:

Created on 2019-09-02 17:51 by uppalanchupavankumar45@gmail.com, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (7)
msg351027 - (view) Author: Pavan Kumar Uppalanchu (uppalanchupavankumar45@gmail.com) Date: 2019-09-02 17:51
I have printed min('Infinity') and min('infinity') . 
Both are printing different characters. 
In first case , It's printing 'I' and in second case, it's printing 
'F'
msg351028 - (view) Author: Pavan Kumar Uppalanchu (uppalanchupavankumar45@gmail.com) Date: 2019-09-02 17:52
when I try to print min('Infinity') and min (InFinity). In first case, it's printing 'I' and in second case it's printing 'F'. Is this issue or working as Is ?
msg351029 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-09-02 17:58
Here min uses the ASCII value of the letters for comparison. So for 'Infinity' 'I' (73) has the lowest value and for 'inFinity' 'F' (70) has the lowest value as seen below.

>>> list(map(lambda c: (c, ord(c)), 'Infinity'))
[('I', 73), ('n', 110), ('f', 102), ('i', 105), ('n', 110), ('i', 105), ('t', 116), ('y', 121)]
>>> list(map(lambda c: (c, ord(c)), 'inFinity'))
[('i', 105), ('n', 110), ('F', 70), ('i', 105), ('n', 110), ('i', 105), ('t', 116), ('y', 121)]
msg351030 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2019-09-02 18:01
This has nothing in particular do with `min()`.  As strings, 'I' < 'i', and 'F' < 'I'.  For example,

>>> 'I' < 'i'
True

>>> sorted("InFinity")
['F', 'I', 'i', 'i', 'n', 'n', 't', 'y']

That's all working as intended and as documented, so I'm closing this report.
msg351032 - (view) Author: Pavan Kumar Uppalanchu (uppalanchupavankumar45@gmail.com) Date: 2019-09-02 18:09
Hello Tim,

Thanks for your quick response.

Also, THE min("Infinity") is priniting "I".  Practically, the minimum
value is "e" right ?

Regards,
Pavan Uppalanchu

On Mon, Sep 2, 2019 at 11:31 PM Tim Peters <report@bugs.python.org> wrote:
>
>
> Tim Peters <tim@python.org> added the comment:
>
> This has nothing in particular do with `min()`.  As strings, 'I' < 'i', and 'F' < 'I'.  For example,
>
> >>> 'I' < 'i'
> True
>
> >>> sorted("InFinity")
> ['F', 'I', 'i', 'i', 'n', 'n', 't', 'y']
>
> That's all working as intended and as documented, so I'm closing this report.
>
> ----------
> nosy: +tim.peters -xtreak
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue38012>
> _______________________________________
msg351033 - (view) Author: Pavan Kumar Uppalanchu (uppalanchupavankumar45@gmail.com) Date: 2019-09-02 18:13
Hello Karthikeyan,

Thank you very much for your valuable explanation.

Regards,
Pavan Uppalanchu

On Mon, Sep 2, 2019 at 11:28 PM Karthikeyan Singaravelan
<report@bugs.python.org> wrote:
>
>
> Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:
>
> Here min uses the ASCII value of the letters for comparison. So for 'Infinity' 'I' (73) has the lowest value and for 'inFinity' 'F' (70) has the lowest value as seen below.
>
> >>> list(map(lambda c: (c, ord(c)), 'Infinity'))
> [('I', 73), ('n', 110), ('f', 102), ('i', 105), ('n', 110), ('i', 105), ('t', 116), ('y', 121)]
> >>> list(map(lambda c: (c, ord(c)), 'inFinity'))
> [('i', 105), ('n', 110), ('F', 70), ('i', 105), ('n', 110), ('i', 105), ('t', 116), ('y', 121)]
>
> ----------
> nosy: +xtreak
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue38012>
> _______________________________________
msg351034 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2019-09-02 18:27
> Also, THE min("Infinity") is priniting "I".  Practically,
> the minimum value is "e" right ?

Sorry, I have no idea what "practically" means to you.  It's just a fact that all uppercase ASCII letters compare less than all lowercase ASCII letters:

>>> 'I' < 'e'
True
>>> 'Z' < 'a'
True

This isn't just Python - it's an industry-wide standard.  Look at any reference for the ASCII character set; for example, here:

http://www.asciitable.com/

Try posting about what you're trying to accomplish on the Python mailing list?  The issue tracker isn't the right place for tutorials.
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82193
2019-09-02 18:27:07tim.peterssetmessages: + msg351034
2019-09-02 18:13:03uppalanchupavankumar45@gmail.comsetmessages: + msg351033
2019-09-02 18:09:58uppalanchupavankumar45@gmail.comsetmessages: + msg351032
2019-09-02 18:01:01tim.peterssetstatus: open -> closed
nosy: + tim.peters, - xtreak
messages: + msg351030

resolution: not a bug
stage: resolved
2019-09-02 17:58:07xtreaksetnosy: + xtreak
messages: + msg351029
2019-09-02 17:52:36uppalanchupavankumar45@gmail.comsetmessages: + msg351028
2019-09-02 17:51:03uppalanchupavankumar45@gmail.comcreate