New approach - find split points based on Unicode categories.
[python-collate.git] / collate / _abcollator.py
1 import collate._strings
2
3 class Collator(object):
4 def cmp(self, string1, string2):
5 """Return negative if a < b, zero if a == b, positive if a > b."""
6 return cmp(self.key(string1), self.key(string2))
7
8 def sortemekey(self, string, invalid=float('inf')):
9 keys = []
10 for sorteme in collate._strings.sortemes(string):
11 num, alpha = collate._strings.numeric(sorteme, invalid)
12 if num == invalid:
13 keys.append(self.key(alpha))
14 else:
15 keys.append(num)
16 # Shove the sortkeyed original string on the end to resolve
17 # ties intelligently.
18 return (keys, self.key(string))