projects
/
python-collate.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
33c37b2
)
sortemes: Simplify some logic.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Mon, 22 Feb 2010 00:21:07 +0000
(16:21 -0800)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Mon, 22 Feb 2010 00:21:07 +0000
(16:21 -0800)
collate/strings.py
patch
|
blob
|
history
diff --git
a/collate/strings.py
b/collate/strings.py
index
bc4ed62
..
267c6e5
100644
(file)
--- a/
collate/strings.py
+++ b/
collate/strings.py
@@
-69,23
+69,20
@@
def sortemes(string):
# Split if we find two pieces of punctuation in a row, even
# if we should otherwise continue.
# Split if we find two pieces of punctuation in a row, even
# if we should otherwise continue.
- elif
i > 0 and prev_category[0] == "P" and category[0] ==
"P":
+ elif
prev_category[0] in "P" and category[0] in
"P":
broke = True
mode = UNKNOWN
if broke and start is not None and last is not None:
# If we read two strings separated by weird punctuation,
# pretend the punctuation isn't there.
broke = True
mode = UNKNOWN
if broke and start is not None and last is not None:
# If we read two strings separated by weird punctuation,
# pretend the punctuation isn't there.
- if (this_mode == previous_mode == LETTER
- and words):
+ if this_mode == previous_mode == LETTER:
words[-1] += BREAKER + string[start:last+1]
else:
words[-1] += BREAKER + string[start:last+1]
else:
- # This ensures "foo2 bar" sorts as ["foo ", 2, "bar"]
- # Which sorts after ["foo", "bar"].
- if this_mode == NUMBER and previous_mode == LETTER and words:
+ if this_mode == NUMBER and previous_mode == LETTER:
words[-1] += BREAKER
words.append(string[start:last+1])
words[-1] += BREAKER
words.append(string[start:last+1])
-
previous_mode = this_mode
+ previous_mode = this_mode
if broke:
start = i
if broke:
start = i