Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'comparisons': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'null,': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'nan': 0.16; 'received:69.41.248.83': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'received:gateway01.websitewelcome.com': 0.16; "i'm": 0.27; 'compared': 0.28; 'unknown': 0.28; 'semantics': 0.30; 'implementing': 0.32; 'actual': 0.32; 'objects': 0.32; 'list': 0.32; 'sort': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python- list': 0.33; 'object': 0.33; 'null': 0.34; 'towards': 0.35; 'returned': 0.38; 'point': 0.39; 'being': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'together.': 0.40; 'results': 0.64; 'view': 0.64; 'received:websitewelcome.com': 0.64; 'received:184': 0.67; 'pain': 0.84; '-->': 0.91 Date: Fri, 13 Jan 2012 11:04:48 -0800 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Python Subject: NaN, Null, and Sorting Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:4219 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326484286 news.xs4all.nl 6948 [2001:888:2000:d::a6]:49542 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18937 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 with the semantics that if the returned object is Null, it's actual value is unknown. 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. Thoughts/advice/criticisms/etc? ~Ethan~