Typo.
[python-collate.git] / collate / _abcollator.py
index 99866c3..02cb733 100644 (file)
@@ -1,3 +1,5 @@
+import collate._strings
+
 class Collator(object):
     def cmp(self, string1, string2):
         """Return negative if a < b, zero if a == b, positive if a > b."""
@@ -9,3 +11,13 @@ class Collator(object):
         This split is done using Unicode's definition of whitespace.
         """
         return string.split()
+
+    def sortemes(self, string):
+        return collate._strings.alnumsplit(string)
+
+    def sortemekey(self, string, invalid=float('inf')):
+        words = []
+        for sorteme in self.sortemes(string):
+            num, alpha = collate._strings.numeric(sorteme, invalid)
+            words.append((num, self.key(alpha)))
+        return words