diff options
author | Seth M Morton <seth.m.morton@gmail.com> | 2018-02-14 21:29:28 -0800 |
---|---|---|
committer | Seth M Morton <seth.m.morton@gmail.com> | 2018-02-14 21:33:54 -0800 |
commit | d0150d1cb6064aa94ed52e4408e5a200ca10a3c3 (patch) | |
tree | ccd5e8a8d83971aabdbb84df96e906aa4bb9b7fb | |
parent | b8175a13e89f9f7fc567a3681475abb17e15b8f1 (diff) | |
download | natsort-d0150d1cb6064aa94ed52e4408e5a200ca10a3c3.tar.gz |
natsort version 5.2.0 release.5.2.0
- Add ns.NUMAFTER to cause numbers to be placed after non-numbers.
- Add natcmp function (Python 2 only).
-rw-r--r-- | README.rst | 12 | ||||
-rw-r--r-- | docs/source/changelog.rst | 6 | ||||
-rw-r--r-- | docs/source/examples.rst | 25 | ||||
-rw-r--r-- | natsort/_version.py | 2 |
4 files changed, 38 insertions, 7 deletions
@@ -320,6 +320,12 @@ History These are the last three entries of the changelog. See the package documentation for the complete `changelog <http://natsort.readthedocs.io/en/master/changelog.html>`_. +02-14-2017 v. 5.2.0 ++++++++++++++++++++ + + - Add ``ns.NUMAFTER`` to cause numbers to be placed after non-numbers. + - Add ``natcmp`` function (Python 2 only). + 11-11-2017 v. 5.1.1 +++++++++++++++++++ @@ -331,9 +337,3 @@ for the complete `changelog <http://natsort.readthedocs.io/en/master/changelog.h - Fixed ``StopIteration`` warning on Python 3.6+. - All Unicode input is now normalized. - -04-30-2017 v. 5.0.3 -+++++++++++++++++++ - - - Improved development infrastructure. - - Migrated documentation to ReadTheDocs. diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 475affe..1a1ce3a 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -3,6 +3,12 @@ Changelog --------- +02-14-2017 v. 5.2.0 ++++++++++++++++++++ + + - Add ``ns.NUMAFTER`` to cause numbers to be placed after non-numbers. + - Add ``natcmp`` function (Python 2 only). + 11-11-2017 v. 5.1.1 +++++++++++++++++++ diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 0cf025b..29d1aea 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -245,6 +245,31 @@ need to pass a key to the :meth:`list.sort` method. The function :func:`~natsort_keygen` has the same API as :func:`~natsorted` (minus the `reverse` option). +Natural Sorting with ``cmp`` (Python 2 only) +-------------------------------------------- + +.. note:: + This is a Python2-only feature! The :func:`natcmp` function is not + exposed on Python3. Because this documentation is built with + Python3, you will not find :func:`natcmp` in the API. + +If you are using a legacy codebase that requires you to use :func:`cmp` instead +of a key-function, you can use :func:`~natcmp`. + +.. code-block:: python + + >>> import sys + >>> a = ['2 ft 7 in', '1 ft 5 in', '10 ft 2 in', '2 ft 11 in', '7 ft 6 in'] + >>> if sys.version_info[0] == 2: + ... from natsort import natcmp + ... sorted(a, cmp=natcmp) + ... else: + ... natsorted(a) # so docstrings don't fail + ['1 ft 5 in', '2 ft 7 in', '2 ft 11 in', '7 ft 6 in', '10 ft 2 in'] + +:func:`natcmp` also accepts an ``alg`` argument so you can customize your +sorting experience. + Sorting Multiple Lists According to a Single List ------------------------------------------------- diff --git a/natsort/_version.py b/natsort/_version.py index d96c07f..298c08c 100644 --- a/natsort/_version.py +++ b/natsort/_version.py @@ -6,4 +6,4 @@ from __future__ import ( absolute_import ) -__version__ = '5.1.1' +__version__ = '5.2.0' |