Aufgabe 5 alternative Lambda Funktion implementiert
parent
1d12195402
commit
b9ee7f2538
|
@ -22,12 +22,14 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# Aufgabe 5
|
# Aufgabe 5
|
||||||
list_to_sort = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
list_to_sort = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
||||||
|
list_to_sort.sort(key=lambda x: x[1]) # in-build-function
|
||||||
|
|
||||||
for row in range(len(list_to_sort)):
|
for row in range(len(list_to_sort)):
|
||||||
for next_row in range(row + 1, len(list_to_sort)):
|
for next_row in range(row + 1, len(list_to_sort)):
|
||||||
if list_to_sort[row][1] > list_to_sort[next_row][1]:
|
if list_to_sort[row][1] > list_to_sort[next_row][1]:
|
||||||
list_to_sort[row], list_to_sort[next_row] = list_to_sort[next_row], list_to_sort[row]
|
list_to_sort[row], list_to_sort[next_row] = list_to_sort[next_row], list_to_sort[row]
|
||||||
|
|
||||||
print("The sorted list" + str(list_to_sort))
|
print("The sorted list " + str(list_to_sort))
|
||||||
|
|
||||||
|
|
||||||
# Aufgabe 6
|
# Aufgabe 6
|
||||||
|
|
Loading…
Reference in New Issue