Fix #1021814 (Can't sort numeric column with space as thousands separator)

This commit is contained in:
Kovid Goyal 2012-07-07 09:02:58 +05:30
commit 9ad9e6e391

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import re, itertools, time, traceback
import re, itertools, time, traceback, locale
from itertools import repeat, izip, imap
from datetime import timedelta
from threading import Thread
@ -1082,7 +1082,6 @@ class SortKeyGenerator(object):
dt = 'datetime'
elif sb == 'number':
try:
val = val.replace(',', '').strip()
p = 1
for i, candidate in enumerate(
('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB')):
@ -1090,7 +1089,7 @@ class SortKeyGenerator(object):
p = 1024**(i)
val = val[:-len(candidate)].strip()
break
val = float(val) * p
val = locale.atof(val) * p
except:
val = 0.0
dt = 'float'