473,663 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flexable Collating (feedback please)



I put together the following module today and would like some feedback on any
obvious problems. Or even opinions of weather or not it is a good approach.

While collating is not a difficult thing to do for experienced programmers, I
have seen quite a lot of poorly sorted lists in commercial applications, so it
seems it would be good to have an easy to use ready made API for collating.

I tried to make this both easy to use and flexible. My first thoughts was to
try and target actual uses such as Phone directory sorting, or Library sorting,
etc., but it seemed using keywords to alter the behavior is both easier and more
flexible.

I think the regular expressions I used to parse leading and trailing numerals
could be improved. They work, but you will probably get inconsistent results if
the strings are not well formed. Any suggestions on this would be appreciated.

Should I try to extend it to cover dates and currency sorting? Probably those
types should be converted before sorting, but maybe sometimes it's useful
not to?

Another variation is collating dewy decimal strings. It should be easy to add
if someone thinks that might be useful.

I haven't tested this in *anything* yet, so don't plug it into production code
of any type. I also haven't done any performance testing.

See the doc tests below for examples of how it's used.

Cheers,
Ron Adam

"""
Collate.py

A general purpose configurable collate module.

Collation can be modified with the following keywords:

CAPS_FIRST -Aaa, aaa, Bbb, bbb
HYPHEN_AS_SPACE -Don't ignore hyphens
UNDERSCORE_AS_S PACE -Underscores as white space
IGNORE_LEADING_ WS -Disregard leading white space
NUMERICAL -Digit sequences as numerals
COMMA_IN_NUMERA LS -Allow commas in numerals

* See doctests for examples.

Author: Ron Adam, ro*@ronadam.com, 10/18/2006

"""
import re
import locale
locale.setlocal e(locale.LC_ALL , '') # use current locale settings

# The above line may change the string constants from the string
# module. This may have unintended effects if your program
# assumes they are always the ascii defaults.
CAPS_FIRST = 1
NUMERICAL = 2
HYPHEN_AS_SPACE = 4
UNDERSCORE_AS_S PACE = 8
IGNORE_LEADING_ WS = 16
COMMA_IN_NUMERA LS = 32

class Collate(object) :
""" A general purpose and configurable collator class.
"""
def __init__(self, flag):
self.flag = flag
def transform(self, s):
""" Transform a string for collating.
"""
if self.flag & CAPS_FIRST:
s = s.swapcase()
if self.flag & HYPHEN_AS_SPACE :
s = s.replace('-', ' ')
if self.flag & UNDERSCORE_AS_S PACE:
s = s.replace('_', ' ')
if self.flag & IGNORE_LEADING_ WS:
s = s.strip()
if self.flag & NUMERICAL:
if self.flag & COMMA_IN_NUMERA LS:
rex = re.compile('^(\ d*\,?\d*\.?\d*) (\D*)(\d*\,?\d* \.?\d*)',
re.LOCALE)
else:
rex = re.compile('^(\ d*\.?\d*)(\D*)( \d*\.?\d*)', re.LOCALE)
slist = rex.split(s)
for i, x in enumerate(slist ):
if self.flag & COMMA_IN_NUMERA LS:
x = x.replace(',', '')
try:
slist[i] = float(x)
except:
slist[i] = locale.strxfrm( x)
return slist
return locale.strxfrm( s)

def __call__(self, a, b):
""" This allows the Collate class work as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return cmp(self.transf orm(a), self.transform( b))

def collate(slist, flags=0):
""" Collate list of strings in place.
"""
return slist.sort(Coll ate(flags))

def collated(slist, flags=0):
""" Return a collated list of strings.

This is a decorate-undecorate collate.
"""
collator = Collate(flags)
dd = [(collator.trans form(x), x) for x in slist]
dd.sort()
return list([B for (A, B) in dd])

def _test():
"""
DOC TESTS AND EXAMPLES:

Sort (and sorted) normally order all words beginning with caps
before all words beginning with lower case.
>>t = ['tuesday', 'Tuesday', 'Monday', 'monday']
sorted(t) # regular sort
['Monday', 'Tuesday', 'monday', 'tuesday']

Locale collation puts words beginning with caps after words
beginning with lower case of the same letter.
>>collated(t)
['monday', 'Monday', 'tuesday', 'Tuesday']

The CAPS_FIRST option can be used to put all words beginning
with caps after words beginning in lowercase of the same letter.
>>collated(t, CAPS_FIRST)
['Monday', 'monday', 'Tuesday', 'tuesday']
The HYPHEN_AS_SPACE option causes hyphens to be equal to space.
>>t = ['a-b', 'b-a', 'aa-b', 'bb-a']
collated(t)
['aa-b', 'a-b', 'b-a', 'bb-a']
>>collated(t, HYPHEN_AS_SPACE )
['a-b', 'aa-b', 'b-a', 'bb-a']
The IGNORE_LEADING_ WS and UNDERSCORE_AS_S PACE options can be
used together to improve ordering in some situations.
>>t = ['sum', '__str__', 'about', ' round']
collated(t)
[' round', '__str__', 'about', 'sum']
>>collated(t, IGNORE_LEADING_ WS)
['__str__', 'about', ' round', 'sum']
>>collated(t, UNDERSCORE_AS_S PACE)
[' round', '__str__', 'about', 'sum']
>>collated(t, IGNORE_LEADING_ WS|UNDERSCORE_A S_SPACE)
['about', ' round', '__str__', 'sum']
The NUMERICAL option orders leading and trailing digits as numerals.
>>t = ['a5', 'a40', '4abc', '20abc', 'a10.2', '13.5b', 'b2']
collated(t, NUMERICAL)
['4abc', '13.5b', '20abc', 'a5', 'a10.2', 'a40', 'b2']
The COMMA_IN_NUMERA LS option ignores commas instead of using them to
seperate numerals.
>>t = ['a5', 'a4,000', '500b', '100,000b']
collated(t, NUMERICAL|COMMA _IN_NUMERALS)
['500b', '100,000b', 'a5', 'a4,000']
Collating also can be done in place using collate() instead of collated().
>>t = ['Fred', 'Ron', 'Carol', 'Bob']
collate(t)
t
['Bob', 'Carol', 'Fred', 'Ron']

"""
import doctest
doctest.testmod ()
if __name__ == '__main__':
_test()

Oct 18 '06 #1
17 1893

Fixed...
Changed the collate() function to return None the same as sort() since it is an
in place collate.

A comment in _test() doctests was reversed. CAPS_FIRST option puts words
beginning with capitals before, not after, words beginning with lower case of
the same letter.
It seems I always find a few obvious glitches right after I post something. ;-)

Cheers,
Ron
Oct 18 '06 #2


On Oct 18, 2:42 am, Ron Adam <r...@ronadam.c omwrote:
I put together the following module today and would like some feedback on any
obvious problems. Or even opinions of weather or not it is a good approach.
,,,
def __call__(self, a, b):
""" This allows the Collate class work as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return cmp(self.transf orm(a), self.transform( b))

You document _call__ as useful for the "key" keyword to sort, but you
implement it for the "cmp" keyword. The "key" allows much better
performance, since it's called only once per value. Maybe just :
return self.transform( a)

-- George

Oct 18 '06 #3
ge**********@gm ail.com wrote:
>
On Oct 18, 2:42 am, Ron Adam <r...@ronadam.c omwrote:
>I put together the following module today and would like some feedback on any
obvious problems. Or even opinions of weather or not it is a good approach.
,,,
def __call__(self, a, b):
""" This allows the Collate class work as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return cmp(self.transf orm(a), self.transform( b))

You document _call__ as useful for the "key" keyword to sort, but you
implement it for the "cmp" keyword. The "key" allows much better
performance, since it's called only once per value. Maybe just :
return self.transform( a)

-- George

Thanks, I changed it to the following...

def __call__(self, a):
""" This allows the Collate class work as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return self.transform( a)

And also changed the sort call here ...
def collate(slist, flags=0):
""" Collate list of strings in place.
"""
slist.sort(key= Collate(flags)) <<<
Today I'll do some performance tests to see how much faster it is for moderate
sized lists.
Cheers,
Ron


Oct 18 '06 #4
This part of code uses integer "constants" to be or-ed (or added):

CAPS_FIRST = 1
NUMERICAL = 2
HYPHEN_AS_SPACE = 4
UNDERSCORE_AS_S PACE = 8
IGNORE_LEADING_ WS = 16
COMMA_IN_NUMERA LS = 32

....

def __init__(self, flag):
self.flag = flag
def transform(self, s):
""" Transform a string for collating.
"""
if self.flag & CAPS_FIRST:
s = s.swapcase()
if self.flag & HYPHEN_AS_SPACE :
s = s.replace('-', ' ')
if self.flag & UNDERSCORE_AS_S PACE:
s = s.replace('_', ' ')
if self.flag & IGNORE_LEADING_ WS:
s = s.strip()
if self.flag & NUMERICAL:
if self.flag & COMMA_IN_NUMERA LS:

This is used in C, but maybe for Python other solutions may be better.
I can see some different (untested) solutions:

1)

def selfassign(self , locals):
# Code from web.py, modified.
for key, value in locals.iteritem s():
if key != 'self':
setattr(self, key, value)

def __init__(self,
caps_first=Fals e,
hyphen_as_space =False,
underscore_as_s pace=False,
ignore_leading_ ws=False,
numerical=False ,
comma_in_numera ls=False):
selfassign(self , locals())

def transform(self, s):
if self.caps_first :
...

Disadvangages: if a flag is added/modified, the code has to be modified
in two places.
2)

def __init__(self, **kwds):
self.lflags = [k for k,v in kwds.items() if v]
def transform(self, s):
if "caps_first " in self.lflags:
...

This class can be created with 1 instead of Trues, to shorten the code.

Disadvantages: the user of this class has to read from the class
doctring or from from the docs the list of possible flags (and such
docs can be out of sync from the code).
3)

Tkinter (Tcl) shows that sometimes strings are better than int
constants (like using "left" instead of tkinter.LEFT, etc), so this is
another possibile solution:

def __init__(self, flags=""):
self.lflags = flags.lower().s plit()
def transform(self, s):
if "caps_first " in self.lflags:
...

An example of calling this class:

.... = Collate("caps_f irst hyphen_as_space numerical")

I like this third (nonstandard) solution enough.

Bye,
bearophile

Oct 18 '06 #5

I made a number of changes ... (the new version is listed below)
These changes also resulted in improving the speed by about 3 times when all
flags are specified.

Collating now takes about 1/3 (or less) time. Although it is still quite a bit
slower than a bare list.sort(), that is to be expected as collate is locale
aware and does additional transformations on the data which you would need to do
anyways. The tests where done with Unicode strings as well.

Changed the flag types from integer values to a list of named strings. The
reason for this is it makes finding errors easier and you can examine the flags
attribute and get a readable list of flags.

A better regular expression for separating numerals. It now separates numerals
in the middle of the string.

Changed flag COMMA_IN_NUMERA LS to IGNORE_COMMAS, This was how it was implemented.

Added flag PERIOD_AS_COMMA S

This lets you collate decimal separated numbers correctly such as version
numbers and internet address's. It also prevents numerals from being
interpreted as floating point or decimal.

It might make more since to implement it as PERIOD_IS_SEPAR ATOR. Needed?

Other minor changes to doc strings and tests were made.
Any feedback is welcome.

Cheers,
Ron

"""
Collate.py

A general purpose configurable collate module.

Collation can be modified with the following keywords:

CAPS_FIRST -Aaa, aaa, Bbb, bbb
HYPHEN_AS_SPACE -Don't ignore hyphens
UNDERSCORE_AS_S PACE -Underscores as white space
IGNORE_LEADING_ WS -Disregard leading white space
NUMERICAL -Digit sequences as numerals
IGNORE_COMMAS -Allow commas in numerals
PERIOD_AS_COMMA S -Periods can separate numerals.

* See doctests for examples.

Author: Ron Adam, ro*@ronadam.com

"""
__version__ = '0.02 (pre-alpha) 10/18/2006'

import re
import locale
import string

locale.setlocal e(locale.LC_ALL , '') # use current locale settings

# The above line may change the string constants from the string
# module. This may have unintended effects if your program
# assumes they are always the ascii defaults.

CAPS_FIRST = 'CAPS_FIRST'
HYPHEN_AS_SPACE = 'HYPHEN_AS_SPAC E'
UNDERSCORE_AS_S PACE = 'UNDERSCORE_AS_ SPACE'
IGNORE_LEADING_ WS = 'IGNORE_LEADING _WS'
NUMERICAL = 'NUMERICAL'
IGNORE_COMMAS = 'IGNORE_COMMAS'
PERIOD_AS_COMMA S = 'PERIOD_AS_COMM AS'

class Collate(object) :
""" A general purpose and configurable collator class.
"""
def __init__(self, flags=[]):
self.flags = flags
self.numrex = re.compile(r'([\d\.]*|\D*)', re.LOCALE)
self.txtable = []
if HYPHEN_AS_SPACE in flags:
self.txtable.ap pend(('-', ' '))
if UNDERSCORE_AS_S PACE in flags:
self.txtable.ap pend(('_', ' '))
if PERIOD_AS_COMMA S in flags:
self.txtable.ap pend(('.', ','))
if IGNORE_COMMAS in flags:
self.txtable.ap pend((',', ''))
self.flags = flags

def transform(self, s):
""" Transform a string for collating.
"""
if not self.flags:
return locale.strxfrm( s)
for a, b in self.txtable:
s = s.replace(a, b)
if IGNORE_LEADING_ WS in self.flags:
s = s.strip()
if CAPS_FIRST in self.flags:
s = s.swapcase()
if NUMERICAL in self.flags:
slist = self.numrex.spl it(s)
for i, x in enumerate(slist ):
try:
slist[i] = float(x)
except:
slist[i] = locale.strxfrm( x)
return slist
return locale.strxfrm( s)

def __call__(self, a):
""" This allows the Collate class work as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return self.transform( a)

def collate(slist, flags=[]):
""" Collate list of strings in place.
"""
slist.sort(key= Collate(flags). transform)

def collated(slist, flags=[]):
""" Return a collated list of strings.
"""
return sorted(slist, key=Collate(fla gs).transform)

def _test():
"""
DOC TESTS AND EXAMPLES:

Sort (and sorted) normally order all words beginning with caps
before all words beginning with lower case.
>>t = ['tuesday', 'Tuesday', 'Monday', 'monday']
sorted(t) # regular sort
['Monday', 'Tuesday', 'monday', 'tuesday']

Locale collation puts words beginning with caps after words
beginning with lower case of the same letter.
>>collated(t)
['monday', 'Monday', 'tuesday', 'Tuesday']

The CAPS_FIRST option can be used to put all words beginning
with caps before words beginning in lowercase of the same letter.
>>collated(t, [CAPS_FIRST])
['Monday', 'monday', 'Tuesday', 'tuesday']
The HYPHEN_AS_SPACE option causes hyphens to be equal to space.
>>t = ['a-b', 'b-a', 'aa-b', 'bb-a']
collated(t)
['aa-b', 'a-b', 'b-a', 'bb-a']
>>collated(t, [HYPHEN_AS_SPACE])
['a-b', 'aa-b', 'b-a', 'bb-a']
The IGNORE_LEADING_ WS and UNDERSCORE_AS_S PACE options can be
used together to improve ordering in some situations.
>>t = ['sum', '__str__', 'about', ' round']
collated(t)
[' round', '__str__', 'about', 'sum']
>>collated(t, [IGNORE_LEADING_ WS])
['__str__', 'about', ' round', 'sum']
>>collated(t, [UNDERSCORE_AS_S PACE])
[' round', '__str__', 'about', 'sum']
>>collated(t, [IGNORE_LEADING_ WS, UNDERSCORE_AS_S PACE])
['about', ' round', '__str__', 'sum']
The NUMERICAL option orders sequences of digits as numerals.
>>t = ['a5', 'a40', '4abc', '20abc', 'a10.2', '13.5b', 'b2']
collated(t, [NUMERICAL])
['4abc', '13.5b', '20abc', 'a5', 'a10.2', 'a40', 'b2']
The IGNORE_COMMAS option prevents commas from seperating numerals.
>>t = ['a5', 'a4,000', '500b', '100,000b']
collated(t, [NUMERICAL, IGNORE_COMMAS])
['500b', '100,000b', 'a5', 'a4,000']
The PERIOD_AS_COMMA S option can be used to sort version numbers
and other decimal seperated numbers correctly.
>>t = ['5.1.1', '5.10.12','5.2. 2', '5.2.19' ]
collated(t, [NUMERICAL, PERIOD_AS_COMMA S])
['5.1.1', '5.2.2', '5.2.19', '5.10.12']

Collate also can be done in place by using collate() instead of
collated().
>>t = ['Fred', 'Ron', 'Carol', 'Bob']
collate(t)
t
['Bob', 'Carol', 'Fred', 'Ron']

"""
import doctest
doctest.testmod ()
if __name__ == '__main__':
_test()

Oct 18 '06 #6

Thanks, But I fixed it already. (almost) ;-)

I think I will use strings as you suggest, and verify they are valid so a type
don't go though silently.

I ended up using string based option list. I agree a space separated string is
better and easier from a user point of view.

The advantage of the list is it can be iterated without splitting first. But
that's a minor thing. self.options = options.lower() .split(' ') fixes that easily.
Once I'm sure it's not going to get any major changes I'll post this as a
recipe. I think it's almost there.

Cheers and thanks,
Ron

be************@ lycos.com wrote:
This part of code uses integer "constants" to be or-ed (or added):

CAPS_FIRST = 1
NUMERICAL = 2
HYPHEN_AS_SPACE = 4
UNDERSCORE_AS_S PACE = 8
IGNORE_LEADING_ WS = 16
COMMA_IN_NUMERA LS = 32

...

def __init__(self, flag):
self.flag = flag
def transform(self, s):
""" Transform a string for collating.
"""
if self.flag & CAPS_FIRST:
s = s.swapcase()
if self.flag & HYPHEN_AS_SPACE :
s = s.replace('-', ' ')
if self.flag & UNDERSCORE_AS_S PACE:
s = s.replace('_', ' ')
if self.flag & IGNORE_LEADING_ WS:
s = s.strip()
if self.flag & NUMERICAL:
if self.flag & COMMA_IN_NUMERA LS:

This is used in C, but maybe for Python other solutions may be better.
I can see some different (untested) solutions:

1)

def selfassign(self , locals):
# Code from web.py, modified.
for key, value in locals.iteritem s():
if key != 'self':
setattr(self, key, value)

def __init__(self,
caps_first=Fals e,
hyphen_as_space =False,
underscore_as_s pace=False,
ignore_leading_ ws=False,
numerical=False ,
comma_in_numera ls=False):
selfassign(self , locals())

def transform(self, s):
if self.caps_first :
...

Disadvangages: if a flag is added/modified, the code has to be modified
in two places.
2)

def __init__(self, **kwds):
self.lflags = [k for k,v in kwds.items() if v]
def transform(self, s):
if "caps_first " in self.lflags:
...

This class can be created with 1 instead of Trues, to shorten the code.

Disadvantages: the user of this class has to read from the class
doctring or from from the docs the list of possible flags (and such
docs can be out of sync from the code).
3)

Tkinter (Tcl) shows that sometimes strings are better than int
constants (like using "left" instead of tkinter.LEFT, etc), so this is
another possibile solution:

I think maybe this is better, but I need to verify the flags so typos don't go
though silently.
def __init__(self, flags=""):
self.lflags = flags.lower().s plit()
def transform(self, s):
if "caps_first " in self.lflags:
...

An example of calling this class:

... = Collate("caps_f irst hyphen_as_space numerical")

I like this third (nonstandard) solution enough.

Bye,
bearophile
Oct 18 '06 #7


This is how I changed it...

(I edited out the test and imports for posting here.)

locale.setlocal e(locale.LC_ALL , '') # use current locale settings

class Collate(object) :
""" A general purpose and configurable collator class.
"""
options = [ 'CAPS_FIRST', 'NUMERICAL', 'HYPHEN_AS_SPAC E',
'UNDERSCORE_AS_ SPACE', 'IGNORE_LEADING _WS',
'IGNORE_COMMAS' , 'PERIOD_AS_COMM AS' ]

def __init__(self, flags=""):
if flags:
flags = flags.upper().s plit()
for value in flags:
if value not in self.options:
raise ValueError, 'Invalid option: %s' % value
self.txtable = []
if 'HYPHEN_AS_SPAC E' in flags:
self.txtable.ap pend(('-', ' '))
if 'UNDERSCORE_AS_ SPACE' in flags:
self.txtable.ap pend(('_', ' '))
if 'PERIOD_AS_COMM AS' in flags:
self.txtable.ap pend(('.', ','))
if 'IGNORE_COMMAS' in flags:
self.txtable.ap pend((',', ''))
self.flags = flags
self.numrex = re.compile(r'([\d\.]*|\D*)', re.LOCALE)

def transform(self, s):
""" Transform a string for collating.
"""
if not self.flags:
return locale.strxfrm( s)
for a, b in self.txtable:
s = s.replace(a, b)
if 'IGNORE_LEADING _WS' in self.flags:
s = s.strip()
if 'CAPS_FIRST' in self.flags:
s = s.swapcase()
if 'NUMERICAL' in self.flags:
slist = self.numrex.spl it(s)
for i, x in enumerate(slist ):
try:
slist[i] = float(x)
except:
slist[i] = locale.strxfrm( x)
return slist
return locale.strxfrm( s)

def __call__(self, a):
""" This allows the Collate class to be used as a sort key.

USE: list.sort(key=C ollate(flags))
"""
return self.transform( a)

def collate(slist, flags=[]):
""" Collate list of strings in place.
"""
slist.sort(key= Collate(flags). transform)

def collated(slist, flags=[]):
""" Return a collated list of strings.
"""
return sorted(slist, key=Collate(fla gs).transform)

Oct 18 '06 #8
Ron Adam:

Insted of:

def __init__(self, flags=[]):
self.flags = flags
self.numrex = re.compile(r'([\d\.]*|\D*)', re.LOCALE)
self.txtable = []
if HYPHEN_AS_SPACE in flags:
self.txtable.ap pend(('-', ' '))
if UNDERSCORE_AS_S PACE in flags:
self.txtable.ap pend(('_', ' '))
if PERIOD_AS_COMMA S in flags:
self.txtable.ap pend(('.', ','))
if IGNORE_COMMAS in flags:
self.txtable.ap pend((',', ''))
self.flags = flags

I think using a not mutable flags default is safer, this is an
alternative (NOT tested!):

numrex = re.compile(r'[\d\.]* | \D*', re.LOCALE|re.VE RBOSE)
dflags = {"hyphen_as_spa ce": ('-', ' '),
"underscore_as_ space": ('_', ' '),
"period_as_comm as": ('_', ' '),
"ignore_commas" : (',', ''),
...
}

def __init__(self, flags=()):
self.flags = [fl.strip().lowe r() for fl in flags]
self.txtable = []
df = self.__class__. dflags
for flag in self.flags:
if flag in df:
self.txtable.ap pend(df[flag])
...

This is just an idea, it surely has some problems that have to be
fixed.

Bye,
bearophile

Oct 18 '06 #9
At Wednesday 18/10/2006 03:42, Ron Adam wrote:
>I put together the following module today and would like some feedback on any
obvious problems. Or even opinions of weather or not it is a good approach.
if self.flag & CAPS_FIRST:
s = s.swapcase()
This is just coincidental; it relies on (lowercase)<(up percase) on
the locale collating sequence, and I don't see why it should be always so.
if self.flag & IGNORE_LEADING_ WS:
s = s.strip()
This ignores trailing ws too. (lstrip?)
if self.flag & NUMERICAL:
if self.flag & COMMA_IN_NUMERA LS:
rex =
re.compile('^(\ d*\,?\d*\.?\d*) (\D*)(\d*\,?\d* \.?\d*)',
re.LOCALE)
else:
rex = re.compile('^(\ d*\.?\d*)(\D*)( \d*\.?\d*)', re.LOCALE)
slist = rex.split(s)
for i, x in enumerate(slist ):
if self.flag & COMMA_IN_NUMERA LS:
x = x.replace(',', '')
try:
slist[i] = float(x)
except:
slist[i] = locale.strxfrm( x)
return slist
return locale.strxfrm( s)
You should try to make this part a bit more generic. If you are
concerned about locales, do not use "comma" explicitely. In other
countries 10*100=1.000 - and 1,234 is a fraction between 1 and 2.
The NUMERICAL option orders leading and trailing digits as numerals.
>>t = ['a5', 'a40', '4abc', '20abc', 'a10.2', '13.5b', 'b2']
>>collated(t, NUMERICAL)
['4abc', '13.5b', '20abc', 'a5', 'a10.2', 'a40', 'b2']
From the name "NUMERICAL" I would expect this sorting: b2, 4abc, a5,
a10.2, 13.5b, 20abc, a40 (that is, sorting as numbers only).
Maybe GROUP_NUMBERS.. . but I dont like that too much either...
--
Gabriel Genellina
Softlab SRL

_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Oct 18 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5214
by: Mindful_Spirit | last post by:
I'm trying to set up a basic email feed back form like this, and was wondering about some basic configuration settings. I have used code from this website. I have it working just fine. I'm running IIS on my home machine. My problem is that I need to upload this stuff to a webhosting place and register a domain and I'm not sure what to put as the smtp mail server value
1
2665
by: Yaro | last post by:
Hi We want to create case-insensitive database (DB2 8.2.2 Win) . I found information we need create custom collating sequence and create database with this sequence but I can't find informations how do this. Can anyone tell me how create case-insensitive collating sequence (sample or link) and how set this sequence in CREATE DATABASE command? Thanks in advance.
0
1101
by: Sammy | last post by:
I'm soliciting feedback from our users about our autonomic computing features in DB2 UDB LUW. If you have used any of the following features, and would like to share positive or negative experiences, please contact me in confidence. We are interested in both your success stories, and constructive feedback. (please see contact intructions below). Also, if you have a positive experience to share and would like us to use your experience in...
1
4620
by: T | last post by:
Hi I am using Windows 2000(SP4) and recently had MS ACCESS 2000 (9.0.2720) installed. My problem is I cannot create or open any database without getting the following message "Select Collating Sequence not supported by the operating system". I have searched around this and other forums and the only suggestion is to update the CollatingSequence key in the registry which I have done but my problem still exists.
0
2103
by: HelmutStoneCorner | last post by:
Hi, I am connected as a german client to a multilanguage server, Regional Options: English, US. Western Europe and US. The W2K Server (Terminal) -version: english(US) runs a french database. My regional options are: General: English, US, (Keybd: german). I create a new database and, opening the table or going to the options, I get: An error occurred and this feature is no longer functioning properly - then: Selected collating sequence...
0
1601
by: pam | last post by:
We have a customer who would like to see their data sorted in a case- insensitive manner. I've tried several of the out of the box collating sequences (identity, system, compatibility) but none of them result in the ordering they would like to see. Has anyone used the Create Database API to pass in a custom collating sequence that would result in a case-insensitive sort (ie a=A for weight)? Are there samples of how to do this? Any...
9
2497
by: gs | last post by:
the feedback for the install of c#2008 places 97 to 99% cpu load for way too long on athlon x64 3800+ PC. 3/4 an hour later its only about 80% complete, continuing with 98% CPU load! Next time installing visual studio /dot product I will likely make sure no feedback
0
1849
by: Frank Swarbrick | last post by:
What might be a good test to demonstrate the difference between the SYSTEM (UNIQUE?) collating sequence and the IDENTITY collating sequence? Thanks, Frank
3
1502
by: David Thielen | last post by:
Hi all; Since everyone here is great about feedback - what do you think of this design for an XPath wizard? This is for people who span the gamut from barely know what an XML file is to programmers. http://www.windwardreports.com/mktg/Videos/AutoTag7_XpathWizard/First_Peek_Xpath_Wizard.html thanks - dave
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.