12575eaed844603f039009a62262fe66b8d29ace
3 class Collator(object):
6 def cmp(self
, string1
, string2
):
7 """Return negative if a < b, zero if a == b, positive if a > b."""
8 return cmp(self
.key(string1
), self
.key(string2
))
10 def key(self
, string
):
13 def words(self
, string
):
14 """Split the string along word boundries."""
15 if isinstance(string
, str):
16 string
= string
.decode(self
.encoding
, 'replace')
19 def sortemekey(self
, string
):
20 """Return a key based on sortemes of a string.
22 If the string is a str instance, it is decoded to a unicode
23 instance according to the 'encoding' attribute of the
26 if isinstance(string
, str):
27 string
= string
.decode(self
.encoding
, 'replace')
29 # Shove the sortkeyed original string on the end to resolve
31 return (collate
.strings
.sortemes(string
, self
.key
),