Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4aef41ff
Commit
4aef41ff
authored
Nov 20, 2005
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove import string and use string methods
parent
4737b234
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
Doc/howto/sorting.tex
Doc/howto/sorting.tex
+3
-4
No files found.
Doc/howto/sorting.tex
View file @
4aef41ff
...
@@ -110,11 +110,10 @@ types, do the forward sort first, then use the \method{reverse()} method.
...
@@ -110,11 +110,10 @@ types, do the forward sort first, then use the \method{reverse()} method.
Here's a case-insensitive string comparison using a
\keyword
{
lambda
}
function:
Here's a case-insensitive string comparison using a
\keyword
{
lambda
}
function:
\begin{verbatim}
\begin{verbatim}
>>> import string
>>> a = "This is a test string from Andrew".split()
>>> a = string.split("This is a test string from Andrew.")
>>> a.sort(lambda x, y: cmp(x.lower(), y.lower()))
>>> a.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
>>> print a
>>> print a
['a', 'Andrew
.
', 'from', 'is', 'string', 'test', 'This']
['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']
\end{verbatim}
\end{verbatim}
This goes through the overhead of converting a word to lower case
This goes through the overhead of converting a word to lower case
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment