I have a string list and a float list, they both print vertically using a For Loop.
**PS. The outputs are meant to be vertical,not horizontal. I don't know why it's shown that way, probably because I'm new to this platform.
Current Output:
for i in range(0,5,1):
print(string[I], float[i], "s")
Output:
String1 20 s
String2 40 s
String3 10 s
String4 60 s
String5 80 s
My Objective: I want to sort them by the numbers in ascending order.
Objective:
Output:
String3 10 s
String1 20 s
String2 40 s
String4 60 s
String5 80 s
Trial and Error Attempts:
I tried to use the .sort()
function. However, it sorts the numbers but the names don't correspond to the numbers that were originally assigned to them.
I want the numbers and strings to be joined together and sort them both by only using the numbers (float) in ascending order.