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: A lists which list.sort seems to leave out of order.
Type: behavior Stage: resolved
Components: Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, throwaway, twouters
Priority: normal Keywords:

Created on 2010-02-12 02:13 by throwaway, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg99249 - (view) Author: Alex Coventry (throwaway) Date: 2010-02-12 02:13
I feel like I must be on crack, here.  I apologize if  so.  English version: sorting this long list leaves in place element 580395, which is less than element 0.  Restricting to a list of just those two elements, sorting does what I'd expect.

met% python2.6                                             # This problem also happens with 2.5
Python 2.6b1+ (trunk:64955, Jul 14 2008, 17:23:39) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, cPickle
>>> t = cPickle.load(os.popen('gunzip -c list.pickle.gz')) # Load the pickle in.  It's a list of pairs of numbers
>>> t.sort()                                               # Sort the pickle
>>> t[580395] < t[0]                                       # It's not in order!
True
>>> u = [t[0], t[580395]]                                  # Make a list of just the two compared elements and sort
>>> u.sort()
>>> u == [t[580395], t[0]]                                 # Now it's in order!
True
>>>
msg99250 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-02-12 02:22
Could you provide the list in another format (e.g. in a plain .py script or as a .txt file)?
msg99252 - (view) Author: Alex Coventry (throwaway) Date: 2010-02-12 02:27
No.  It's 10M, gzipped.  It's constructed from genome-wide association
data, which is also huge, intrinsically complex, and protected by rules
regarding research on humans.  If the bug tracker won't take it do I
have any other options?
msg99253 - (view) Author: Alex Coventry (throwaway) Date: 2010-02-12 02:28
Oh, I guess I could make it a gzipped text file.  Hang on.
msg99254 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2010-02-12 02:29
You have a nan in your list of tuples, which screws up the sorting. After the first sort, elements 580395-7 are:

(0.99257340581672904, 551095), 
(nan, 551371),
(6.6494600485570754e-14, 551526),
msg99255 - (view) Author: Alex Coventry (throwaway) Date: 2010-02-12 02:30
Ah, I guess I *was* on crack.  Thanks for the explanation.
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52163
2010-02-12 02:30:52throwawaysetmessages: + msg99255
2010-02-12 02:30:21ezio.melottisetstage: test needed -> resolved
2010-02-12 02:29:18twouterssetstatus: open -> closed

nosy: + twouters
messages: + msg99254

resolution: not a bug
2010-02-12 02:28:32throwawaysetmessages: + msg99253
2010-02-12 02:27:45throwawaysetmessages: + msg99252
2010-02-12 02:23:11ezio.melottisetfiles: - list.pickle.gz
2010-02-12 02:22:53ezio.melottisetpriority: normal
versions: - Python 2.5
nosy: + ezio.melotti

messages: + msg99250

stage: test needed
2010-02-12 02:13:59throwawaycreate