Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:06:32+00:00 2026-06-02T06:06:32+00:00

How does the max function work when items in a list are not of

  • 0

How does the max function work when items in a list are not of the same type?

For example the following code returns [1,’3′]

max([1,52,53],[1,'3']) => [1,'3']
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:06:34+00:00Added an answer on June 2, 2026 at 6:06 am

    In Python2, the default comparison for objects of different types is to compare using the id of their types (obtained by casting the object pointers to integers). Here a link to the source: http://hg.python.org/cpython/file/2.7/Objects/object.c#l757

    On my build, here is the ordering of types:

    >>> sorted([bool, int, float, long, list, tuple, dict, str, unicode])
    [<type 'bool'>, <type 'float'>, <type 'int'>, <type 'list'>, <type 'long'>,
     <type 'dict'>, <type 'str'>, <type 'tuple'>, <type 'unicode'>]
    

    Numbers (except for complex) have compare methods that allow cross type comparison based on numeric value (i.e. a float can be compared with an int).

    The None object is special. It compares less than everything else.

    To see it all put together, use sorted to see the ordering:

    >>> sorted(zoo)
    [None, -5, -5.0, 0, 0.0, -0.0, False, True, 10, 10.0, 11.5, {},
     {'abc': 10}, {'lmno': 20}, [], [1, 2], [1, 2, 3], [1, [2, 3]],
     '', u'', 'alpha', u'alpha', 'bingo', 'cat', (), (1, 2), 
     (1, 2, 3), (1, (2, 3)), u'bingo', u'cat']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following sql, with the MAX aggregrate function in the WHERE clause, does not
I'm having some difficulties with the PathCombine function. It does not seem to work
What method returns a random int between a min and max? Or does no
I count characters using NobleCount and the following code: $('#message').NobleCount('#messageInfo',{ max_chars: getMaxChars(), on_negative: function(t_obj,
Please take a look at the following code: Sort[{1, y, x}, Greater] Max[{1, x,
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in
Does anyone know how to add an item to a list but do it
Does map() iterate through the list like for would? Is there a value in
Can anyone give me an example of how to return the following json simply
The following code displays correctly in Chrome or IE (the image is 200px wide).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.