summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndrew Kuchev <0coming.soon@gmail.com>2015-11-05 15:59:56 +0500
committerTim Graham <timograham@gmail.com>2016-02-23 12:15:08 -0500
commite81d1c995c0cc5573d3627de0fe6b803b2f43fb2 (patch)
tree1b596d09984d0bd284124bce3a502220094f2174 /docs
parentcdbd8745f6c550422170a6ae5928c0b679fab0df (diff)
Fixed #25670 -- Allowed dictsort to sort a list of lists.
Thanks Tim Graham for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/builtins.txt34
-rw-r--r--docs/releases/1.10.txt3
2 files changed, 37 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 21e5321f80..20fcdb02b5 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -1443,6 +1443,40 @@ then the output would be::
* 1984 (George)
* Timequake (Kurt)
+``dictsort`` can also order a list of lists (or any other object implementing
+``__getitem__()``) by elements at specified index. For example::
+
+ {{ value|dictsort:0 }}
+
+If ``value`` is:
+
+.. code-block:: python
+
+ [
+ ('a', '42'),
+ ('c', 'string'),
+ ('b', 'foo'),
+ ]
+
+then the output would be:
+
+.. code-block:: python
+
+ [
+ ('a', '42'),
+ ('b', 'foo'),
+ ('c', 'string'),
+ ]
+
+You must pass the index as an integer rather than a string. The following
+produce empty output::
+
+ {{ values|dictsort:"0" }}
+
+.. versionchanged:: 1.10
+
+ The ability to order a list of lists was added.
+
.. templatefilter:: dictsortreversed
``dictsortreversed``
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index fc7b03d2a7..8bff4e99c6 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -333,6 +333,9 @@ Templates
* Added the ``is`` comparison operator to the :ttag:`if` tag.
+* Allowed :tfilter:`dictsort` to order a list of lists by an element at a
+ specified index.
+
Tests
~~~~~