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 7066697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:43+00:00 2026-05-28T05:06:43+00:00

With NaN, it is possible to get a list that will not properly sort:

  • 0

With NaN, it is possible to get a list that will not properly sort:

--> NaN = float('nan')
--> spam = [1, 2, NaN, 3, NaN, 4, 5, 7, NaN]
--> sorted(spam)
[1, 2, nan, 3, nan, 4, 5, 7, nan]

I’m constructing a Null object that will behave a lot like NaN, with the semantics that if the returned object is Null, it’s actual value is unknown. A Null object will also be able to interact with any other type of object (int, float, str, bool, etc), but any interactions will result in Null.

From a purist point of view if it is unknown then comparison results are also unknown since the actual value might be greater, lesser, or the same as the value being compared against.

From a practical point of view a list with Nulls scattered throughout is a pain in the backside.

So I am strongly leaning towards implementing the comparisons such that Null objects are less than other objects so they will always sort together.

Of course, I could always dodge the issue and force the user to implement custom sort keys.

Any thoughts/advice/criticisms/etc?

  • 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-05-28T05:06:44+00:00Added an answer on May 28, 2026 at 5:06 am

    If the Null object implements comparison behavior, other methods (such as indexing) will get more complicated. Consider:

    target = table.sql('select * where sales < 1000.00')
    

    If Null values compare < all other objects then target could have rows where there were no sales (which is not the goal).

    So, I think practicality and purity are both coming down on the same side on this one: Null comparisons yield unknown. Users will have to decide what to do with Null values if they get them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a command in MATLAB that allows me to find all NaN (Not-a-Number)
Is it possible to check if a number is NaN or not?
Possible Duplicates: Objective-C - float checking for nan Determine if NSNumber is NaN I
float('nan') represents NaN (not a number). But how do I check for it?
The documentation for java.lang.Double.NaN says that it is A constant holding a Not-a-Number (NaN)
From this question I learned Double.NaN is not equal to itself. I was verifying
Can every possible value of a float variable can be represented exactly in a
Why do comparisons of NaN values behave differently from all other values? That is,
I have a float value set to NaN (seen in the Watch Window), but
Is it possible somehow to return 0 instead of NaN when parsing values in

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.