From 4441778c263c075675950c8488882ee4ddac4c12 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 17 Sep 2018 19:54:37 +0500 Subject: [PATCH] Simplified ListMixin.sort(). --- django/contrib/gis/geos/mutable_list.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 90fcc6d587..2d62e7bfa4 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -210,19 +210,9 @@ class ListMixin: "Standard list reverse method" self[:] = self[-1::-1] - def sort(self, cmp=None, key=None, reverse=False): + def sort(self, key=None, reverse=False): "Standard list sort method" - if key: - temp = [(key(v), v) for v in self] - temp.sort(key=lambda x: x[0], reverse=reverse) - self[:] = [v[1] for v in temp] - else: - temp = list(self) - if cmp is not None: - temp.sort(cmp=cmp, reverse=reverse) - else: - temp.sort(reverse=reverse) - self[:] = temp + self[:] = sorted(self, key=key, reverse=reverse) # ### Private routines ### def _rebuild(self, newLen, newItems):