* The "cmp" function has been removed, so we must not use it any more;
* The "cmp" keyword argument of the "sorted" function has been removed, so
replace it with "key=functool.cmp_to_key".
Change-Id: Ic39d29dc1002a68f36f04c32e53a36bc826dce78
Blueprint: neutron-python3
# License for the specific language governing permissions and limitations
# under the License.
+import functools
import urllib
from oslo_config import cfg
def sort(self, items):
def cmp_func(obj1, obj2):
for key, direction in self.sort_dict:
- ret = cmp(obj1[key], obj2[key])
+ ret = (obj1[key] > obj2[key]) - (obj1[key] < obj2[key])
if ret:
return ret * (1 if direction else -1)
return 0
- return sorted(items, cmp=cmp_func)
+ return sorted(items, key=functools.cmp_to_key(cmp_func))
class SortingNativeHelper(SortingHelper):