Page 1 of 1

Wie sortieren Sie eine Liste von Tupeln, ohne Sort () oder lambda () zu verwenden?

Posted: 08 Apr 2025, 16:16
by Anonymous
Ich muss eine Liste von Tupeln sortieren, ohne eine integrierte Funktion zu verwenden (wie sort () oder lambda ()). < /p>
Ich weiß, wie man eine normale Liste wie SO sortiert:

Code: Select all

a=[2,1,3]
for i in range(0, len(a)):
for j in range(i+1,len(a)):
if (a[i]>a[j]):
a[i],a[j]=a[j],a[i]
return a
My output is: [1,2,3]
However, when it comes to sorting a list of tuples like (("b", 32), ("c", 1), ("a", 23)) and that I have to reorder it in order of the second element without using sort() or lambda() or any in-built function, I don't know how to do Es. Kann mir bitte jemand helfen?:)