我正在尝试编写一个过程来根据每个元组的乘积值对列表中的元组进行排序。我只是尝试先使用 while 循环对它们进行排序,但我无法整合元组内数字的乘法。到目前为止我的代码是:
def sort_list (a):
i = 0
while i < len(a):
key = i
j = i + 1
#first checking throuh the whole list if any number is bigger
while j < len(a):
if a[key] > a [j]:
key = j
j += 1
#swap the numbers if the key one (i) is bigger than the j one the j one will be the new key
# and swapped in the next section!
a[i], a[key] = a[key], …Run Code Online (Sandbox Code Playgroud)