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

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie sortieren Sie eine Liste von Tupeln, ohne Sort () oder lambda () zu verwenden?

by Anonymous » 08 Apr 2025, 16:16

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?:)

Top