抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

blaire

👩🏻‍💻ブレア🥣

image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-
"""
@file: tt_sort.py
@date: 2020-10-20 10:41 AM
"""
import copy
from functools import cmp_to_key


def rule(a, b):
if a > b:
return 1
if a < b:
return -1
return 0


L = [7, 4, 8, 2, 9, 6]

L2 = copy.copy(L)

L.sort(key=cmp_to_key(rule))

print(sorted(L2, key=cmp_to_key(rule)))
print(L)
# print(L2)

print(''.join([str(num) for num in L2]))

Reference

Comments