Using Bubble sort, it would be something like:
def sortTuple(t):
for i in range(0, len(t)):
for j in range(0, len(t)-i-1):
if (t[j][1] > t[j + 1][1]):
temp = t[j]
t[j]= t[j + 1]
t[j + 1]= temp
return t
ex = [('apple', 10, '1/1/2021'), ('banana', 5,'1/1/2021'), ('mango', 20,'1/1/2021')]
print(sortTuple(ex))
Output : [('banana', 5,'1/1/2021'), ('apple', 10, '1/1/2021'), ('mango', 20,'1/1/2021')]
So, all you need is to:
1. extract the price data out from tuple
2. use that data in a simple bubble sort algorithm
More about tuples:
Python - Tuples - Tutorialspoint[
^]