Opened 15 years ago
Closed 15 years ago
#12110 closed (duplicate)
dictsort is not stable sort
Reported by: | eronen | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.1 |
Severity: | Keywords: | dictsort | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm trying to sort a list first by owner, then by date, like this:
{% for item in items|dictsort:"date"|dictsort:"owner" %}
Python's sort method is stable (preserves the order if the sort key is the same), so I assumed dictsort would be, too.
But it's not!
Ticket #11008 has a patch which fixes this problem, too (although #11008 is not
about sort stability as such).
Note:
See TracTickets
for help on using tickets.
Duplicate of #11008 (if you interpret that ticket as "dictsort is broken")