Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94e21cf

Browse filesBrowse files
gh-92780: Improve sqlite3.Connection.create_collation docs (GH-92790)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> (cherry picked from commit 7ee19e2) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
1 parent 1815d8e commit 94e21cf
Copy full SHA for 94e21cf

File tree

1 file changed

+8
-11
lines changed
Filter options

1 file changed

+8
-11
lines changed

‎Doc/library/sqlite3.rst

Copy file name to clipboardExpand all lines: Doc/library/sqlite3.rst
+8-11Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,19 @@ Connection Objects
436436

437437
.. method:: create_collation(name, callable)
438438

439-
Creates a collation with the specified *name* and *callable*. The callable will
440-
be passed two string arguments. It should return -1 if the first is ordered
441-
lower than the second, 0 if they are ordered equal and 1 if the first is ordered
442-
higher than the second. Note that this controls sorting (ORDER BY in SQL) so
443-
your comparisons don't affect other SQL operations.
439+
Create a collation named *name* using the collating function *callable*.
440+
*callable* is passed two :class:`string <str>` arguments,
441+
and it should return an :class:`integer <int>`:
444442

445-
Note that the callable will get its parameters as Python bytestrings, which will
446-
normally be encoded in UTF-8.
443+
* ``1`` if the first is ordered higher than the second
444+
* ``-1`` if the first is ordered lower than the second
445+
* ``0`` if they are ordered equal
447446

448-
The following example shows a custom collation that sorts "the wrong way":
447+
The following example shows a reverse sorting collation:
449448

450449
.. literalinclude:: ../includes/sqlite3/collation_reverse.py
451450

452-
To remove a collation, call ``create_collation`` with ``None`` as callable::
453-
454-
con.create_collation("reverse", None)
451+
Remove a collation function by setting *callable* to :const:`None`.
455452

456453

457454
.. method:: interrupt()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.