def sort_age(lst):
    result=[]
    while lst:
        largest=lst[0][1]
        tuple_largest=lst[0]
        for i in lst:
            if i[1]>largest:
                largest=i[1]
                tuple_largest=i
        lst.remove(tuple_largest)
        result.append(tuple_largest)
    return result


def sort_age(lst):

    people = []

    while lst:

        i = lst[0]

        for a in lst:

            if a[1] >= i[1] :

                i = a

        lst.remove(i)

        people.append(i)

    return people

Task: Sorting Tuples

Can we sort items other than integers? For this question, you will be sorting tuples!
We represent a person using a tuple (<gender>, <age>). Given a list of people, write
a function sort_age that sorts the people and return a list in an order such that the older
people are at the front of the list. An example of the list of people is [("M", 23), ("F",
19), ("M", 30)]. The sorted list would look like [("M", 30), ("M", 23), ("F", 19)]. You
may assume that no two members in the list of people are of the same age.


def sort(lst):
    for i in range(len(lst)-1):
        if lst[i][1] > lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
        else:
            continue
    return lst

def sort_age(lst):
    oldlist = tuple(lst)
    if tuple(sort(lst)) == oldlist:
        lst.reverse()
        return lst
    else:
        sort(lst)
        return sort_age(lst)


def sort_age(lst):
    if len(lst) < 2:
        return lst
    for j in range(len(lst)-1):
        minimum = j
        for i in range(j+1, len(lst)):
            if lst[minimum][1] > lst[i][1]:
                minimum = i
        lst[j], lst[minimum] = lst[minimum], lst[j]
    lst.reverse()
    return lst


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for element in lst:
            if element[1] > largest[1]:
                largest = element
        lst.remove(largest)
        sort.append(largest)
    return sort

#def sort_age(lst):
#    lst.sort(key= lambda x: x[1], reverse = True)
#    return lst


def sort_age(lst):
    a = lst
    sort = []
    while   a: # a is not []
        smallest = a[0][1]
        b=a[0]
        for element in  a:
            if element[1] > smallest:
                smallest = element[1]
                b=element
        a.remove(b)
        sort.append(b)
    return sort


def sort_age(lst):
    if len(lst) == 1:
        return lst
    else:
        new_list = []
        while lst:
            minimum = lst[0]
            for i in lst:
                if i[1] < minimum[1]:
                    minimum = i
            new_list.append(minimum)
            lst.remove(minimum)
        return new_list[::-1]


def sort_age(lst):
    sorted1 = []
    while lst:
        largest = lst[0]
        for element in lst:
            if element[1] > largest[1]:
                largest = element
        lst.remove(largest)
        sorted1.append(largest)
    return sorted1


def sort_age(lst):
    sort_list = []
    while lst: # a is not []
        biggest = lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest = element
        lst.remove(biggest)
        sort_list.append(biggest)
    return sort_list


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for e in lst:
            print(e)
            if e[1] > biggest[1]:
                biggest = e
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    for item in range(len(lst)):
        for test in range(len(lst)):
            if lst[test][1] < lst[item][1]:
                lst[test], lst[item] = lst[item], lst[test]
    return lst


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1]>oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
	result = []
	while lst:
		largest = lst[0]
		for x in lst:
			if x[1] > largest[1]:
				largest = x
		lst.remove(largest)
		result.append(largest)
	return result


def sort_age(lst):
    new_lst = []
    for i in lst:
        if new_lst ==[]:
            new_lst+=[i]
        else:
            pos=0
            for x in new_lst:
                if i[1]<x[1]:
                    pos+=1
                else:
                    continue
            new_lst[pos:pos]=[i]
    return new_lst


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                swap = True
    return lst


def sort_age(lst):
    l=lst.copy()
    res=[]
    while l:
        biggest=l[0]

        for element in l:
            if element[1]>biggest[1]:
                biggest=element

        l.remove(biggest)
        res.append(biggest)
    return res


def sort_age(lst):
    result = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        result.append(largest)
    return result
    pass


def sort_age(lst):
    new = []
    while lst:
        curr = lst[0]
        for i in lst:
            if i[1]>curr[1]:
                curr = i
        lst.remove(curr)
        new.append(curr)

    return new


def sort_age(lst):
    sort = []
    while lst: # a is not [ ]
        biggest = lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    def merge(left,right):
        results = []
        while left and right:
            if left[0][1] > right[0][1]:
                results.append(left.pop(0))
            else:
                results.append(right.pop(0))
        results.extend(left)
        results.extend(right)
        return results
    if len(lst) < 2:
        return lst
    mid = len(lst)//2
    left = sort_age(lst[:mid])
    right = sort_age(lst[mid:])
    return merge(left,right)


def sort_age(lst):
    new = []
    while lst:
        eldest = lst[0]
        for i in lst:
            if i[1] > eldest[1]:
                eldest = i
        lst.remove(eldest)
        new.append(eldest)
    return new


def sort_age(lst):
    i=0
    while i+1<len(lst):
        if lst[i][1]<lst[i+1][1]:
            lst.extend([lst[i]])
            del lst[i]
            i=0
        else:
            i+=1
    return lst


def sort_age(lst):
	final = []
	while lst:
		largest = lst[0]
		for i in lst:
			if i[1] > largest[1]:
				largest = i
		lst.remove(largest)
		final.append(largest)
	return final


def sort_age(lst):
    males, females = [], []
    for i in lst:
        if i[0] == "M":
            males = males + [lst[0],]
        elif i[0] == "F":
            females = females + [lst[0],]
        lst = lst[1:]
    return merge(merge_sort(males), merge_sort(females))

def merge(left, right):
    results = []
    while left and right:
        if left[0][1] > right[0][1]:
            results.append(left.pop(0))
        else:
            results.append(right.pop(0))
    results.extend(left)
    results.extend(right)
    return results

def merge_sort(lst):
    if len(lst) < 2:
        return lst
    mid = len(lst) // 2
    left = merge_sort(lst[:mid])
    right = merge_sort(lst[mid:])
    return merge(left, right)


def sort_age(lst):
    sorted = []
    while lst:
        biggest = lst[0]
        for elem in lst:
            if elem[1] > biggest[1]:
                biggest = elem
        lst.remove(biggest)
        sorted.append(biggest)
    return sorted


def sort_age(lst):
    new = []
    while lst:
        small = lst[0][1]
        name =lst[0][0]
        for ele in lst:
            if ele[1]>small:
                small = ele[1]
                name = ele[0]
        new.append((name,small))
        lst.remove((name,small))
    return new


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        new.append(largest)
    return new


def sort_age(lst):
    a = []
    for i in lst:
        a.append(i[1])
    sort = []
    while a:
        largest = a[0]
        for element in a:
            if element > largest:
                largest = element
        a.remove(largest)
        sort.append(largest)
    lst2 = []
    counter = 0
    for i in sort:
        for j in lst:
            if j[1] == i:
                lst2.append(j)
                counter += 1
    return lst2


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for i in lst:
            if largest[1] < i[1]:
                largest = i
            else:
                continue
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    result=[]
    while lst:
        minimum=lst[0]
        for i in lst:
            if i[1]<minimum[1]:
                minimum=i
        result.append(minimum)
        lst.remove(minimum)
    return result[::-1]


def sort_age(lst):
    if lst == []:
        return []
    else:
        max_age = max(lst, key = lambda x: x[1])
        lst.remove(max_age)
        return [max_age] + sort_age(lst)


def sort_age(lst):
    sort = True
    while sort:
        sort = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                sort = True
                lst[i], lst[i+1] = lst[i+1], lst[i]
    return lst


def sort_age(lst):
	if len(lst) < 2:
		return lst
	mid = len(lst) // 2
	left = sort_age(lst[:mid])
	right = sort_age(lst[mid:])
	return merge(left, right)

def merge(left, right):
	results = []
	while left and right:
		if left[0][1] < right[0][1]:
			results.append(right.pop(0))
		else:
			results.append(left.pop(0))
	results.extend(left)
	results.extend(right)
	return results


def sort_age(lst):
    new_lst = []

    while lst:
        big_age = lst[0]
        for i in lst:
            if i[1] > big_age[1]:
                big_age = i
        lst.remove(big_age)
        new_lst.append(big_age)
    return new_lst


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i],lst[i+1] = lst[i+1],lst[i]
                swap = True
    return lst


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for element in lst:
            if element[1] > largest[1]:
                largest = element
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    for i in range(len(lst)-1):
        for j in range(i, len(lst)):
            if lst[j][1] > lst[i][1]:
                x = lst[i]
                lst[i] = lst[j]
                lst[j] = x
    return lst


def sort_age(lst):
    for i in range(len(lst)):
        for j in range(i+1,len(lst)):
            if lst[i][1]<lst[j][1]:
                lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):
    # Fill in your code here
    new_lst = []
    while lst:
        largest = lst[0]
        for element in lst:
            if largest[1] < element[1]:
                largest = element
        lst.remove(largest)
        new_lst.append(largest)
    return new_lst


def sort_age(lst):
    new_list = []
    while lst:
        eldest = lst[0]
        for i in lst:
            if i[1] > eldest[1]:
                eldest = i
        lst.remove(eldest)
        new_list.append(eldest)
    return new_list


def sort_age(lst):
	age_list = []
	result = ()
	for x in lst:
		age_list.append(list(x))
	sort = []
	while age_list:
		largest = age_list[0]
		for element in age_list:
			if element[1] > largest[1]:
				largest = element
		age_list.remove(largest)
		sort.append(largest)
	for x in sort:
		result += ((x[0],x[1]),)
	return list(result)


def sort_age(lst):
    for i in range(len(lst)-1):
        for ele in range(i+1, len(lst)):
            if lst[i][1] < lst[ele][1]:
                lst[i], lst[ele] = lst[ele], lst[i]
    return lst


def sort_age(lst):
    sortt = [] #empty list
    while lst:
        largest = lst[0] #let the first element be the largest first
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        sortt.append(largest)
    return sortt


def sort_age(lst):
    a=[]
    while lst:
        biggest=lst[0]
        for i in lst:
            if i[1] >= biggest[1]:
                biggest=i
        lst.remove(biggest)
        a.append(biggest)
    return a


def sort_age(lst):
    new_lst = []
    while lst:
        new_lst.append(max_age(lst))
        lst.remove(max_age(lst))
    return new_lst

def max_age(lst):
    member = lst[0]
    for i in lst:
        if i[1] > member[1]:
            member = i
    return member


def sort_age(lst):
    sorted_lst = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(smallest)
        sorted_lst.append(smallest)
    sorted_lst.reverse()
    return sorted_lst


def sort_age(lst):
    a = lst
    for i in range(len(lst)):
        for i in range(len(a)-1):
            if a[i][1] < a[i+1][1]:
                a[i], a[i+1] = a[i+1], a[i]
    return a


def sort_age(lst):
	newlst = []
	while lst:
		newlst += (max(lst, key = lambda x: x[1]),)
		lst.remove(max(lst, key = lambda x: x[1]))
	return newlst


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        largestx = lst[0][1]
        for element in lst:
            if element[1] > largestx:
                largestx = element[1]
                largest = element
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    l=lst.copy()
    res=[]
    while l:
        biggest=l[0]

        for element in l:
            if element[1]>biggest[1]:
                biggest=element

        l.remove(biggest)
        res.append(biggest)
    return res


def sort_age(lst):
    for i, e in enumerate(lst):
        mx = max(range(i,len(lst)), key= lambda x: lst[x][1])
        lst[i], lst[mx] = lst[mx], e
    return lst


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    return new_lst


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0]
        for item in a:
            if item[1] >largest[1]:
                largest = item
        a.remove(largest)
        sort.append(largest)

    return(sort)# Fill in your code here


def sort_age(lst):
    newlst = []
    while lst:
        largest = lst[0]
        for el in lst:
            if el[1] > largest[1]:
                largest = el
        newlst.append(largest)
        lst.remove(largest) #when it repeats, largest will take on the new first element in lst
    return newlst


def sort_age(lst):
    swap = True
    while swap == True:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                swap = True
    return lst


def sort_age(lst):
    new = []
    while lst:
        eldest = lst[0]
        for i in lst:
            if i[1] > eldest[1]:
                eldest = i
        lst.remove(eldest)
        new.append(eldest)
    return new


def swap_positions(lst):
	new_lst = []
	for i in range(0, len(lst)):
		new_lst.append((lst[i][1], lst[i][0]))
	return new_lst

def sort_age(lst):
	swapped_lst = swap_positions(lst)
	new_lst =[]
	while (swapped_lst != []):
		new_lst.append(max(swapped_lst))
		swapped_lst.remove(max(swapped_lst))
	return swap_positions(new_lst)


def sort_age(lst):

    sort = []

    while lst:

        largest = lst[0]

        for x in lst:

            if x[1] > largest[1]:

                largest = x

        lst.remove(largest)

        sort.append(largest)

    return sort


def sort_age(lst):
	if len(lst) == 0:
		return lst
	else:
	    smallest = lst[0]
	    newlist = []
	    while lst:
		    for item in lst:
		    	if item[1] <= smallest[1]:
			    	smallest = item
		    lst.remove(smallest)
		    newlist.insert(0,smallest)
		    if len(lst) == 0:
			    break
		    smallest = lst[0]
	    return newlist


def func(lst, x):
    index = len(lst)
    for i in range(len(lst)):
        if lst[i][1] < x:
            continue
        else:
            index = i
            break
    return index

def sort_age(lst):
    newlist = []
    for i in range(len(lst)):
        age = lst[i][1]
        b = func(newlist, age)
        newlist.insert(b, lst[i])
    return list(reversed(newlist))


def sort_age(lst):
    sort = []
    while lst: # a is not [ ]
        biggest = lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    if lst == []:
        return []
    else:
        agelist = [lst[0],]
        for i in range(1,len(lst)):
            if lst[i][1] > agelist[0][1]:
                agelist.insert(0, lst[i])
            elif lst[i][1] < agelist[len(agelist)-1][1]:
                agelist.insert(len(agelist), lst[i])
            else:
                for x in range(0,len(agelist)):
                    if agelist[x][1]> lst[i][1] > agelist[x+1][1]:
                        agelist.insert(x+1, lst[i])
                        break
        return agelist


def sort_age(lst):
    newlst=[]
    lstages=[i[1] for i in lst]
    while lst:
        for i in lst:
            if i[1] == max(lstages):
                newlst+=[i]
                lst.remove(i)
                lstages.remove(i[1])
    return newlst


def sort_age(lst):
    if len(lst)<=1:
        return lst
    else:
        used_lst=lst.copy()
        ages=()
        for i in lst:
            ages+=(i[1],)
        for i in lst:
            if i[1]==max(ages):
                new_lst=[i]
                used_lst.remove(i)
        return new_lst+sort_age(used_lst)


def sort_age(lst):
    for x in range(len(lst)):
        max = x
        for i in range(x, len(lst)):
            if lst[i][1] > lst[max][1]:
                max = i
        lst[max], lst[x] = lst[x], lst[max]
    return lst


def sort_age(lst):
    sorted = []
    while lst:
        oldest = lst[0]
        for element in lst:
            if element[1] > oldest[1]:
                oldest = element
        lst.remove(oldest)
        sorted.append(oldest)
    return sorted


def sort_age(lst):
	for k in range(len(lst)-1):
		for i in range(k+1, len(lst)):
			if lst[k][1] < lst[i][1]:
				lst[k], lst[i] = lst[i], lst[k]
			else:
			    continue
	return lst


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                swap = True
    return lst


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0][1]
        for i in lst:
            if i[1] > largest:
                largest = i[1]
        for j in lst:
            if largest in j:
                lst.remove(j)
                new.append(j)
    return new


def sort_age(lst):
	new_lst = []
	while lst:
		biggest = lst[0]
		for i in lst:
			if i[1] > biggest[1]:
				biggest = i
		lst.remove(biggest)
		new_lst.append(biggest)
	return new_lst


def sort_age(lst):
    newlst = []
    while lst:
        maximum = lst[0]
        for i in lst:
            if i[1]>maximum[1]:
                maximum = i

        newlst.append(maximum)
        lst.remove(maximum)
    return newlst


def sort_age(lst):
    sort = []

    while lst:
        largest_element = lst[0]
        largest_value = lst[0][1]
        for element in lst:
            if element[1] > largest_value:
                largest_element = element
                largest_value = element[1]
            else:
                continue
        lst.remove(largest_element)
        sort.append(largest_element)
    return sort


def sort_age(lst):
    n = len(lst) - 1
    while n > 0:
        for i in range(n):
            if lst[i][1] > lst[i + 1][1]:
                lst[i],lst[i + 1] = lst[i + 1], lst[i]
        n = n-1
    lst.reverse()
    return lst


def sort_age(lst):
    sort=[]
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        sort.append(smallest)
        lst.remove(smallest)
    sort.reverse()
    return sort


def sort_age(lst):
    for i in range(len(lst)):
        maxi=lst[i][1]
        for j in range (i+1,len(lst)):
            if lst[j][1]>maxi:
                maxi=lst[j][1]
                lst[i],lst[j]=lst[j],lst[i]

    return lst


def sort_age(lst):
    decoy = []
    decoy2 = []
    final = []
    for i in lst:
        decoy.append(i[1])
    while decoy != []:
        decoy2.append(max(decoy))
        decoy.remove(max(decoy))
    for i in decoy2:
        for j in lst:
            if i == j[1]:
                final.append(j)
    return final


def sort_age(lst):
    newlst = []
    while lst:
        i = lst[0]
        for element in lst:
            if element[1] >= i[1]:
                i = element
        lst.remove(i)
        newlst.append(i)
    return newlst


def sort_age(lst):
    sort = []

    while len(lst) > 0:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i

        lst.remove(largest)
        sort.append(largest)

    return sort


def sort_age(lst):
    # Fill in your code here
    new_lst = []
    while lst:
        largest = lst[0]
        for element in lst:
            if largest[1] < element[1]:
                largest = element
        lst.remove(largest)
        new_lst.append(largest)
    return new_lst


def sort_age(lst):
    for start in range(len(lst)-1):
        oldest = start
        for i in range(start, len(lst)):
            if lst[i][1] > lst[oldest][1]:
                oldest = i
        lst[start], lst[oldest] = lst[oldest], lst[start]
    return list(lst)


def sort_age(lst):
    if len(lst)<2:
        return lst
    def merge(lst1, lst2, key):
        r=[]
        while lst1!=[] and lst2!=[]:
            if key(lst1[0])>key(lst2[0]):
                r.append(lst1[0])
                lst1.remove(lst1[0])
            else:
                r.append(lst2[0])
                lst2.remove(lst2[0])
        r.extend(lst1)
        r.extend(lst2)
        return r
    m=len(lst)//2
    key=lambda tup: tup[1]
    return merge(sort_age(lst[:m]), sort_age(lst[m:]), key)


def sort_age(lst):
    for i in range(len(lst)):
        for j in range(len(lst)-1-i):
            if lst[j][1] < lst[j+1][1]:
                lst[j], lst[j+1] = lst[j+1], lst[j]
    return lst


def sort_age(lst):
    sort = []
    while lst:
        smallest = lst[0]
        for element in lst:
            if element[1] > smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)
    return sort

    pass


def sort_age(lst):
    sort_lst = []
    while lst:
        high = lst[0]
        for i in lst:
            if i[1] > high[1]:
                high = i
        lst.remove(high)
        sort_lst.append(high)
    return sort_lst


def sort_age(lst):
    n = len(lst)
    result = []
    while n != 0:
        test = []
        for counter in range(n):
            test.append(lst[counter][1])
        first = max(test)
        for counter in range(n):
            if counter == len(lst):
                break
            elif lst[counter][1] == first:
                result.append(lst.pop(counter))
        n = len(lst)
    return result


def sort_age(lst):
    if len(lst)<2:
        return lst
    while True:
        changed = False
        for i in range(len(lst)-1):
            if lst[i+1][1]>lst[i][1]:
                lst[i],lst[i+1] = lst[i+1], lst[i]
                changed = True
        if not changed:
            break

    return (lst)


def sort_age(lst):
    new_lst = []
    while lst:
        max_num = lst[0]
        for i in lst:
            if i[1] > max_num[1]:
                max_num = i
        lst.remove(max_num)
        new_lst.append(max_num)
    return new_lst


def sort_age(lst):
    sorted_lst = []
    def oldest_in(lst):
        oldshit = lst[0]
        for i in lst:
            if oldshit[1] < i[1]:
                oldshit = i
        return oldshit
    while lst:
        old = oldest_in(lst)
        lst.remove(old)
        sorted_lst.append(old)
    return sorted_lst


def sort_age(lst):
    result = []
    while lst:
        biggest = lst[0]
        for e in lst:
            if e[1] > biggest[1]:
                biggest = e
        result.append(biggest)
        lst.remove(biggest)
    return result


def sort_age(lst):
    a=[]
    while lst:
        biggest=lst[0]
        for i in lst:
            if i[1] >= biggest[1]:
                biggest=i
        lst.remove(biggest)
        a.append(biggest)
    return a


def sort_age(lst):
    if len(lst) < 2:
        return lst
    for j in range(len(lst)-1):
        minimum = j
        for i in range(j+1, len(lst)):
            if lst[minimum][1] > lst[i][1]:
                minimum = i
        lst[j], lst[minimum] = lst[minimum], lst[j]
    lst.reverse()
    return lst


def sort_age(lst):
    def get_age(person):
        return person[1]
    for i in range(len(lst)-1):
        for elem in lst[i+1:]:
            if get_age(elem) < get_age(lst[i]):
            #    lst[i], lst[lst.index(elem)] = lst[lst.index(elem)], lst[i]
            #above doesn't seem to change the list
                temp = lst.index(elem)
                lst[i], lst[temp] = lst[temp], lst[i]
    lst.reverse()
    return lst


def sort_age(lst):
    sort = []
    while lst:
        smallest = lst[0]
        print(type(smallest))
        for element in lst:
            print(type(element[1]))
            if element[1] > smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)
    return sort


def sort_age(lst):
    sorted = []
    while lst:
        oldest = lst[0]
        for element in lst:
            if element[1] > oldest[1]:
                oldest = element
        lst.remove(oldest)
        sorted.append(oldest)
    return sorted


def sort_age(lst):
    sort = []
    while lst:
        smallest = lst[0]
        for element in lst:
            if element[1] > smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)
    return sort


def sort_age(lst):
    if len(lst) == 1:
        return lst
    sort = []
    while lst:
        tup = lst[0]
        smallest = lst[0][1]
        for element in lst:
            if element[1] > smallest:
                smallest = element[1]
                tup = element
        lst.remove(tup)
        sort.append(tup)
    return sort


def sort_age(lst):
    def age(i):
        return i[1]

    def position(seq, ele):
        n = len(seq)
        for i in range(n):
            if seq[i] == ele:
                return i

    def largest_age(seq):
        largest = age(seq[0])
        largest_pos = 0
        for i in seq:
            if age(i) > largest:
                largest = age(i)
                largest_pos = position(seq,i)
        return seq[largest_pos]
    n = len(lst)
    final = []
    if n ==0:
        return []
    elif n ==1:
        return lst
    else:
        final = [largest_age(lst)]
        lst.remove(largest_age(lst))
        final = final + sort_age(lst)
        return final


def sort_age(lst):
    unsorted = lst
    sort = []
    while unsorted:
        oldest = unsorted[0]
        for i in unsorted[1:]:
            if i[1] > oldest[1]:
                oldest = i
        sort += [oldest,]
        unsorted.remove(oldest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for x in lst:
            if x[1] > oldest[1]:
                oldest = x
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                swap = True
    return lst


def sort_age(lst):
    for i in range(0,len(lst)):
        for y in range(1+i,len(lst)):
            if lst[y][1] > lst[i][1]:
                lst[y],lst[i] = lst[i],lst[y]
    return lst

#alt

#def sort_age(lst):
    #sort = []
    #while lst:
        #biggest = lst[0]
        #for people in lst:
            #if people[1] > biggest[1]:
                #biggest = people
        #lst.remove(biggest)
        #sort.append(biggest)
    #return sort


def sort_age(lst):
    if len(lst) == 1:
        return lst
    else:
        for j in range(len(lst) -1):
            for i in range(len(lst) -1):
                if lst[i][1] < lst[i+1][1]:
                    lst[i], lst[i+1] = lst[i+1], lst[i]

    return lst


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for tag in range(len(lst)-1):
            if lst[tag][1] < lst[tag+1][1]:
                lst[tag], lst[tag+1] = lst[tag+1], lst[tag]
                swap = True
    return lst


def sort_age(lst):
    result=[]
    while lst:
        biggest=lst[0][1]
        tuple_biggest=lst[0]
        for i in lst:
            if i[1]>biggest:
                biggest=i[1]
                tuple_biggest=i
        lst.remove(tuple_biggest)
        result.append(tuple_biggest)
    return result


def sort_age(lst):
    for start in range(len(lst)):
        minimum = start
        for i in range(start,len(lst)):
            if lst[i][1] < lst[minimum][1]:
                minimum = i
        lst[start], lst[minimum] = lst[minimum], lst[start]
    lst.reverse()
    return lst


def sort_age(lst):
    list1 = []
    while lst:
        biggest = lst[0]

        for i in lst:
            if i[1] > biggest[1]:
                biggest = i

        lst.remove(biggest)
        list1.append(biggest)
    return list1


def sort_age(lst):
    n = len(lst) - 1
    while n > 0:
        for i in range(n):
            if lst[i][1] > lst[i + 1][1]:
                lst[i],lst[i + 1] = lst[i + 1], lst[i]
        n = n-1
    lst.reverse()
    return lst


def sort_age(lst):
	for j in range(len(lst) -1):
		for i in range(len(lst) -1):
			if lst[i][1] < lst[i+1][1]:
				lst[i], lst[i+1] = lst[i+1], lst[i]
	return lst


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    return new_lst


def sort_age(lst):
	for i in range(len(lst)):
		for j in range(i+1, len(lst)):
			if lst[j][1] > lst[i][1]:
				#swap
				lst[i],lst[j] = lst[j],lst[i]
	return lst


def sort_age(lst):
    newlst = []
    while lst:
        i = lst[0]
        for element in lst:
            if element[1] >= i[1]:
                i = element
        lst.remove(i)
        newlst.append(i)
    return newlst


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        new.append(largest)
    return new


def sort_age(lst):
    for i in range(0,len(lst)-1):
        for j in range(i+1,len(lst)):
            if lst[i][1]<lst[j][1]:
                lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):
    result = []
    while lst:
        largest = lst[0][1]
        index = 0
        for i in range(len(lst)):
            if lst[i][1] > largest:
                index = i
                largest = lst[i][1]
        result.append(lst[index])
        lst.remove(lst[index])
    return result


def sort_age(lst):
    # Fill in your code here
    sorted_list = []
    while lst:
        tpl = lst[0]
        gender = lst[0][0]
        oldest = lst[0][1]
        for i in lst:
            if i[1] > oldest:
                oldest = i[1]
                tpl = i
                gender = i[0]
        lst.remove(tpl)
        sorted_list.append((gender, oldest))
    return sorted_list


def sort_age(lst):
    res = []
    a=age_list(lst)
    while lst:
        for i in lst:
            if max(a) == i[1]:
                highest=i
                res= res + [i]
        lst.remove(highest)
        a.remove(highest[1])
    return res

def age_list(lst):
    age_list= []
    for i in range(len(lst)):
        age_list = age_list+ [lst[i][1]]
    return age_list


def sort_age(lst):
    s = []
    while lst:
        smallest = lst[0]
        for element in lst:
            if element[1]<smallest[1]:
                smallest = element
        lst.remove(smallest)
        s.append(smallest)
    s.reverse()
    return s


def sort_age(lst):
    def bubble_sort(lst):
        swap = True
        while swap:
            swap = False
            for i in range(len(lst)-1):
                if lst[i][1]<lst[i+1][1]:
                    lst[i],lst[i+1]=lst[i+1],lst[i]
                    swap =True
        return lst
    return bubble_sort(lst)


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)

    return sort


def sort_age(lst):
    new=[]
    while lst:
        biggest=lst[0]
        for element in lst:
            if element[1]>biggest[1]:
                biggest=element

        lst.remove(biggest)
        new.append(biggest)
    return new


def sort_age(lst):
    for oldest in range(len(lst)-1):
        maxage = oldest
        for i in range(oldest,len(lst)):
            if int(lst[i][1]) > int(lst[maxage][1]):
                maxage = i
        lst[oldest], lst[maxage] = lst[maxage], lst[oldest]
    return lst


def sort_age(lst):
    swap = True
    while swap:
        swap = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i],lst[i+1] = lst[i+1],lst[i]
                swap = True
    return lst


def sort_age(lst):
	i = 0
	while i < len(lst)-1:
	    if lst[i][1] > lst[i+1][1]:
	        i += 1
	    elif lst[i][1] < lst[i+1][1]:
	        lst.append(lst[i])
	        lst.remove(lst[i])
	        sort_age(lst)
	return lst


def sort_age(lst):
    newlst=[]
    lstages=[i[1] for i in lst]
    while lst:
        for i in lst:
            if i[1] == max(lstages):
                newlst+=[i]
                lst.remove(i)
                lstages.remove(i[1])
    return newlst


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0]
        for ele in lst:
            if ele[1] > largest[1]:
                largest = ele
        lst.remove(largest)
        new.append(largest)
    return new


def biggest(lst):
    big=lst[0]
    for i in range (len(lst)):
        if lst[i][1]>big[1]:
            big=lst[i]
        else:
            continue
    return big

def sort_age(lst):
    sorted_lst=[]
    while lst:
        sorted_lst.append(biggest(lst))
        lst.remove(biggest(lst))
    return sorted_lst


def sort_age(lst):
    sort =[]
    while lst:
        biggest = lst[0]
        for i in lst:
            if int(i[1])> biggest[1]:
                biggest = i
        lst.remove(biggest)
        sort.append(biggest)
    return sort
    pass


def sort_age(lst):
    new_list = []
    while lst:
        biggest = lst[0]
        for item in lst:
            if item[1] > biggest[1]:
                biggest = item
        lst.remove(biggest)
        new_list.append(biggest)
    return new_list


def sort_age(lst):
    # Fill in your code here
    sorted_list = []

    while lst:
        oldest = lst[0]

        for element in lst:
            if element[1] > oldest[1]:
                oldest = element

        lst.remove(oldest)
        sorted_list.append(oldest)

    return sorted_list


def sort_age(lst):
    for i in range(len(lst)-1,0,-1):
        for a in range(i):
            if lst[a][1]<lst[a+1][1]:
                temp = lst[a]
                lst[a] = lst[a+1]
                lst[a+1] = temp
    return lst


def sort_age(lst):
    total = ()
    def helper(i, tup):
        if tup == ():
            return (i,)
        elif i[1] > tup[0][1]:
            return (i,)+ tup
        else:
            return (tup[0],) + helper(i, tup[1:])
    for i in lst:
        if total == ():
            total = (i,)
        else:
            total = helper(i, total)
    return list(total)


def sort_age(lst):
	if len(lst) < 2:
		return lst
	mid = len(lst) // 2
	left = sort_age(lst[:mid])
	right = sort_age(lst[mid:])
	return merge(left, right)

def merge(left, right):
	a = []
	while left and right:
		if left[0][1] < right[0][1]:
			a.append(right.pop(0))
		else:
			a.append(left.pop(0))
	a.extend(left)
	a.extend(right)
	return a


def sort_age(lst):
    sort = True
    while sort:
        sort = False
        for i in range(len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                sort = True
                lst[i], lst[i+1] = lst[i+1], lst[i]
    return lst


def sort_age(lst):
    for i in range(len(lst)-1):
        for a in range(i+1, len(lst)):
            if lst[i][1] < lst[a][1]:
                lst[i],lst[a]= lst[a],lst[i]

    return lst


def sort_age(lst):
    newlist=[]
    newlist2=[]
    for elements in lst:
        newlist.append(elements)

    while newlist:
        largest = newlist[0]
        for elements in newlist:
            print (largest)
            if largest[1]<elements[1]:
                largest = elements
        newlist2.append(largest)
        newlist.remove(largest)

    return newlist2
    pass


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for element in lst:
            if element[1] > largest[1]:
                largest = element
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    ans = []
    while lst:
        biggest = lst[0]
        for elem in lst:
            if elem[1] > biggest[1]:
                biggest = elem
        lst.remove(biggest)
        ans.append(biggest)

    return ans


#cannot use this
#def sort_age(lst):
#    lst.sort(key=lambda x: x[1], reverse = True)
#    return lst

def sort_age(lst):
    for i in range(0,len(lst) - 1):
        for j in range(i+1, len(lst)):
            if lst[i][1] < lst[j][1]:
                lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):

    sort = []

    while lst:

        largest = lst[0]

        for x in lst:

            if x[1] > largest[1]:

                largest = x

        lst.remove(largest)

        sort.append(largest)

    return sort


def sort_age(lst):
    for i in range(0,len(lst)-1):
            for j in range(i+1,len(lst)):
                if lst[i][1]<lst[j][1]:
                    lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):
	sort=[]
	for ele in lst:
		if sort==[]:
			sort+=[ele]
		else:
			for i in range(len(sort)):
				if ele[1]<sort[i][1] and i==len(sort)-1:
					sort.append(ele)
				elif ele[1]<sort[i][1]:
					continue
				else:
					sort.insert(i,ele)
					break

	return sort


def sort_age(lst):
    for i in range(len(lst)-1):
        for j in range(i, len(lst)):
            if lst[j][1] > lst[i][1]:
                x = lst[i]
                lst[i] = lst[j]
                lst[j] = x
    return lst


def sort_age(lst):
    for start in range (len(lst) - 1):
        for i in range(start, len(lst)):
            if lst[i][1] > lst[start][1]:
                lst[i], lst[start] = lst[start], lst[i]
    return lst


def sort_age(lst):
    newlist = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
            else:
                continue
        lst.remove(oldest)
        newlist.append(oldest)
    return newlist


def sort_age(lst):
    new_list=[]
    largest=0
    while lst:
        for i in lst:
            if i[1]>largest:
                largest = i[1]
                count=i
        new_list=new_list+[count]
        lst.remove(count)
        largest=0
    return new_list


#def sort_age(lst):
    # Fill in your code here
    #lst.sort(key = lambda x: x[1], reverse = True) #running an operation to mutate the list
    #return lst

def sort_age(lst):
    # Fill in your code here
    sort = []
    n = len(lst)

    for i in range(n):
        smallest = lst[0] #create a variable called "smallest"
        for element in lst: #loop through each element in list
            if element[1] < smallest[1]: #must compare by the same property of element
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)

    sort.reverse() #reverse the list that is sorted
    return sort

def sort_age2(lst):
    sort = []
    while lst: #while there is something in the list
        smallest = lst[0]
        for element in lst:
            if element[1] < smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)

    sort.reverse()
    return sort


def sort_age(lst):
	sorted = []
	while lst:
		largest = lst[0]
		for i in lst:
			if i[1] > largest[1]:
				largest = i
		lst.remove(largest)
		sorted.append(largest)
	return sorted


def sort_age(lst):
    a = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(oldest)
        a.append(oldest)
    return a
    pass


def sort_age(lst):
    result=[]
    while lst:
        minimum=lst[0]
        for i in lst:
            if i[1]<minimum[1]:
                minimum=i
        result.append(minimum)
        lst.remove(minimum)
    return result[::-1]


def sort_age(lst):
    if len(lst) < 2:
        return lst
    for i in range(len(lst)-1):
        min = i
        for j in range(i+1, len(lst)):
            if lst[min][1] > lst[j][1]:
                min = j
        lst[i], lst[min] = lst[min], lst[i]
    lst.reverse()
    return lst# Fill in your code here


def sort_age(lst):
    ages = []
    output = []
    for item in lst:
        ages.append(item[1])
    while ages:
        age = max(ages)
        for item in lst:
            if age == item[1]:
                output.append(item)
                ages.remove(age)
    return output


def sort_age(lst):
    new = []
    for x in lst:
        index = 0
        for i in new:
            if x[1] < i[1]:
                index += 1
        new.insert(index,x)
    return new


def sort_age(lst):
    for j in range(len(lst)-1):
        for i in range(len(lst)-1-j):
            if lst[i][1]< lst[i+1][1]:
                lst[i],lst[i+1] = lst[i+1],lst[i]
    return lst


def sort_age(lst):
    sort =[]
    while lst:
        biggest = lst[0]
        for i in lst:
            if int(i[1])> biggest[1]:
                biggest = i
        lst.remove(biggest)
        sort.append(biggest)
    return sort
    pass


def sort_age(lst):
    for i in range(0,len(lst)-1):
        for j in range(i+1,len(lst)):
            if lst[i][1]<lst[j][1]:
                lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):
    a = []
    b = lst.copy()
    lst.clear()
    for i in b:
        a += [i[1]]
    for i in range(len(a)):
            for i in range(len(a)):
                if a[i] == min(a):
                    if b[i] not in lst:
                        lst.append(b[i])
                        a[i] = (max(a) +1)
    lst.reverse()
    return lst

# sort will work for tuples


def sort_age(lst):
    lst1 = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        lst1.append(largest)
    return lst1


def sort_age(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j][1] > a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a


def sort_age(lst):
    sort_lst = []
    while lst:
        high = lst[0]
        for i in lst:
            if i[1] > high[1]:
                high = i
        lst.remove(high)
        sort_lst.append(high)
    return sort_lst


def sort_age(lst):
    a = []
    for i in lst:
        a.append(i[1])
    sort = []
    while a:
        largest = a[0]
        for element in a:
            if element > largest:
                largest = element
        a.remove(largest)
        sort.append(largest)
    lst2 = []
    counter = 0
    for i in sort:
        for j in lst:
            if j[1] == i:
                lst2.append(j)
                counter += 1
    return lst2


def sort_age(lst):
    result = []
    while lst:
        largest = lst[0][1]
        index = 0
        for i in range(len(lst)):
            if lst[i][1] > largest:
                index = i
                largest = lst[i][1]
        result.append(lst[index])
        lst.remove(lst[index])
    return result


def sort_age(lst):
    oldtoyoung=[]
    while lst:
        younger=lst[0]
        for older in lst:
            if older[1]>younger[1]:
                younger=older
        lst.remove(younger)
        oldtoyoung.append(younger)
    return oldtoyoung


def sort_age(lst):
    final = []
    temp = 0
    while lst:
        biggest = lst[0][1]
        for i in lst:
            if i[1]>=biggest:
                biggest = i[1]
                temp = i
        lst.remove(temp)
        final.append(temp)
    return final


def sort_age(lst):
    lst2 = []
    lst_num = []
    for x in range(len(lst)):
        lst_num.append(lst[x][1])

    lst_num_sorted = []
    while lst_num:
        lst_num_sorted.append(max(lst_num))
        lst_num.remove(max(lst_num))

    for y in lst_num_sorted:
        for z in lst:
            if y == z[1]:
                lst2.append(z)
    return lst2


def sort_age(lst):
    for i in range(len(lst)-1):
        x = i+1
        for j in range(x,len(lst)):
            if lst[i][1] < lst[j][1]:
                lst[i],lst[j]= lst[j], lst[i]
    return lst


def sort_age(lst):
    newlst=[]
    while lst:
        big=lst[0]
        for n in lst:
            if n[1]>big[1]:
                big=n
        lst.remove(big)
        newlst.append(big)
    return newlst


def sort_age(lst):
    all_age = []
    for person in lst:
        all_age += [person[1],]
    result = []
    while len(result) < len(lst):
        for person in lst:
            if person[1] == max(all_age):
                result += (person,)
        all_age.remove(max(all_age))
    return result


def sort_age(lst):
    new_lst = []

    while lst:
        max_age = lst[0]  # arbitrary number in list
        for x in lst:
            if x[1] > max_age[1]:
                max_age = x
        new_lst.append(max_age)
        lst.remove(max_age)
    return new_lst


def sort_age(lst):
    new_list = []
    while lst:
        eldest = lst[0]
        for i in lst:
            if i[1] > eldest[1]:
                eldest = i
        lst.remove(eldest)
        new_list.append(eldest)
    return new_list


def sort_age(lst):
    def helper(lol, lel):
        laugh = []
        while lol and lel:
            if lol[0][1] > lel[0][1]:
                laugh.append(lol.pop(0))
            else:
                laugh.append(right.pop(0))
        laugh.extend(lol)
        laugh.extend(right)
        return laugh
    if len(lst) < 2:
        return list(lst)
    centre = len(lst)//2
    left = sort_age(lst[:centre])
    right = sort_age(lst[centre:])
    return helper(left, right)


def func(lst, x):
    index = len(lst)
    for i in range(len(lst)):
        if lst[i][1] < x:
            continue
        else:
            index = i
            break
    return index

def sort_age(lst):
    newlist = []
    for i in range(len(lst)):
        age = lst[i][1]
        b = func(newlist, age)
        newlist.insert(b, lst[i])
    return list(reversed(newlist))


def sort_age(lst):
    # Fill in your code here
    sorted = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        sorted.append(oldest)
        lst.remove(oldest)
    return sorted


def sort_age(lst):
    if len(lst)==1 or len(lst)==0:
        return lst
    else:
        temp=lst[0][1]
        count=0
        for i in range(len(lst)):
            if lst[i][1]>temp:
                temp=lst[i][1]
                count=i
        result=[lst[count],]
        pop=lst.pop(count)
        return result+sort_age(lst)
    # Fill in your code here
    pass


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for element in lst:
            if element[1] > largest[1]:
                largest = element
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    if lst==[]:
        return []
    new_lst=[lst[0],]
    for x in lst[1:]:
        if x[1] > new_lst[-1][1]:
            new_lst += [x,]
        else:
            count=0
            while count<len(new_lst):
                if x[1] > new_lst[count][1]:
                    count+=1
                    continue
                else:
                    new_lst = new_lst[0:count]+[x,]+new_lst[count:]
                    break
    return new_lst[::-1]


def sort_age(lst):
    sort = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    if lst == []:
        return lst
    else:
        age_lst, new_lst = [], []
        for x in lst:
            age_lst.append(x[1])
        while age_lst:
            max_age = max(age_lst)
            for i in lst:
                if i[1] == max_age:
                    new_lst.append(i)
                    age_lst.remove(i[1])
        return new_lst
    pass


def sort_age(lst):
    l = len(lst)
    for i in range(0, l):
        for j in range(0, l-i-1):
            if (lst[j][1] > lst[j + 1][1]):
                temp = lst[j]
                lst[j]= lst[j + 1]
                lst[j + 1]= temp
    return lst[::-1]


def sort_age(lst):
    newlist = []
    if lst == []:
        return []
    for i in lst :
        if newlist == []:
            newlist = i
        elif i[1] > newlist[1] :
            newlist = i
    lst.remove(newlist)
    return [newlist] + sort_age(lst)

    pass


def sort_age(lst):
    new_list = []
    while lst:
        biggest = lst[0]
        for item in lst:
            if item[1] > biggest[1]:
                biggest = item
        lst.remove(biggest)
        new_list.append(biggest)
    return new_list


def sort_age(lst):
    final = []
    temp = 0
    while lst:
        biggest = lst[0][1]
        for i in lst:
            if i[1]>=biggest:
                biggest = i[1]
                temp = i
        lst.remove(temp)
        final.append(temp)
    return final


def sort_age(lst):
    for i in range(0,len(lst)-1):
        for j in range(i+1,len(lst)):
            if lst[i][1]<lst[j][1]:
                lst[i],lst[j]=lst[j],lst[i]
    return lst


def sort_age(lst):
    lst_len=len(lst)-1
    while lst_len>0:
        for i in range(lst_len):
            if lst[i][1]>lst[i+1][1]:
                lst[i],lst[i+1]=lst[i+1],lst[i]
        lst_len-=1
    return lst[::-1]


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    # Fill in your code here
    newlst=[]
    while lst:
        maximum = lst[0]
        for i in lst:
            if i[1]>maximum[1]:
                maximum = i

        newlst.append(maximum)
        lst.remove(maximum)

    return newlst


def sort_age(lst):
    ages=[]
    for j in lst:
        ages.append(j[1])
    ages=sort(ages)
    new_lst=[]
    for age in ages:
        for i in lst:
            if age==i[1]:
                new_lst.append(i)
    return new_lst

def sort(lst):
    age=[]
    while lst:
        largest=lst[0]
        for elem in lst:
            if elem > largest:
                largest = elem
        lst.remove(largest)
        age.append(largest)
    return age


def sort_age(lst):
    new = []
    for x in lst:
        index = 0
        for i in new:
            if x[1] < i[1]:
                index += 1
        new.insert(index,x)
    return new


def sort_age(lst):
    result = []
    while lst:
        oldest = lst[0]
        for people in lst:
            if people[1] > oldest[1]:
                oldest = people
        lst.remove(oldest)
        result += (oldest,)
    return result


def sort_age(lst):
    while True:
        changed = False
        for i in range (len(lst)-1):
            if lst[i][1] < lst[i+1][1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                changed = True
        if not changed:
            break
    return lst

    # lst.sort(key = lambda x: x[1], reverse= True)
    # return lst


def sort_age(lst):
	def sort(lst):
		counter = 0
		a = list(lst)
		while counter<len(lst):
			previous = a[0]
			for i in range(1,len(lst)):
				if a[i]>previous:
					a[i-1]=a[i]
					a[i]=previous
				else:
					previous = a[i]
			counter += 1
		return a
	A = list(map(lambda x:x[1],lst))
	a = sort(A)
	b = []
	for i in a:
		for y in lst:
			if y[1]==i:
				b.append(y)
	return b


def sort_age(lst):
    slist = []
    while lst:
        elder = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > elder[1]:
                elder = lst[i]
            else:
                continue
        slist.append(elder)
        lst.remove(elder)
    return slist


def sort_age(lst):
	a = 0
	for i in range(len(lst) - 1):
		if lst[i][1] < lst[i+1][1]:
			lst.insert(i, lst[i+1])
			lst.pop(i + 2)
			a += 1
	if a == 0:
		return lst
	else:
		return sort_age(lst)


def sort_age(lst):
    new_lst = []

    while lst:
        max_age = lst[0]  # arbitrary number in list
        for x in lst:
            if x[1] > max_age[1]:
                max_age = x
        new_lst.append(max_age)
        lst.remove(max_age)
    return new_lst


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for a in lst:
            if a[1] > oldest[1]:
                oldest = a
        lst.remove(oldest)
        new_lst.append(oldest)
    return new_lst


def sort_age(lst):
    sorted_age = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
        sorted_age.append(oldest)
        lst.remove(oldest)
    return sorted_age


def sort_age(lst):
    result = []
    while lst !=[]:
        lowest = lst[0][1]
        index = 0
        for i in range(1,len(lst)):
            if lst[i][1]<lowest:
                index = i
                lowest = lst[i][1]
        result = result +[lst[index]]
        lst.pop[index]
    return result


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person > oldest:
                person = oldest
        a.remove(smallest)
        sort.append(smallest)
        print(a)


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person[1] > oldest[1]:
                person = oldest
        a.remove(oldest)
        sort.append(oldest)
        print(sort)


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person[1] > oldest[1]:
                person = oldest
        a.remove(oldest)
        sort.append(oldest)
        print(lst)


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person[1] >= oldest[1]:
                person = oldest
        lst.remove(oldest)
        sort.append(oldest)
    print(lst)


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person[1] >= oldest[1]:
                person = oldest
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    for i in range(0,len(lst)):
        this=lst[i]
        for j in range(0,len(lst)):
            if lst[j][1]<this[1]:
                del lst[i]
                lst=lst[0:j-1]+[this]+lst[j:]
    return lst# Fill in your code here
    pass


def sort_age(lst):
    for i in range(0,len(lst)):
        this=lst[i]
        for j in range(0,len(lst)):
            if lst[j][1]<this[1]:
                del lst[i]
                lst=lst[0:j]+[this]+lst[j:]
    return lst# Fill in your code here
    pass


def sort_age(lst):
    for i in range(0,len(lst)):
        this=lst[i]
        for j in range(0,len(lst)):
            if lst[j][1]<this[1]:
                del lst[i]
                lst=lst[0:j]+[this]+lst[j:]
                break
    return lst


def sort_age(lst):
    for i in range(0,len(lst)):
        this=lst[0]
        for j in range(1,len(lst)+1):
            a=len(lst)-j
            if lst[a][1]>this[1]:
                lst=lst[1:a+1]+[this]+lst[a+1:]
                break
    return lst


def sort_age(lst):
    result = []
    while lst != []:
        largest = lst[0][1]
        for i in lst:
            if i[1] > largest:
                largest_tup = i
                largest = i[1]
        lst.remove(largest_tup)
        result.append(largest_tup)
    return result


def sort_age(lst):
    old_lst = lst
    new_lst = []
    while old_lst:
        largest = old_lst[0]
        for i in lst:
            if i > largest:
                largest = i
        old_lst.remove(largest)
        new_lst.append(largest)
    return new_lst


def sort_age(lst):
    return lst.sort(key=lambda x: x[1], reverse=True)


def sort_age(lst):
    lst.sort(key=lambda x: x[1], reverse=True)
    return lst


def sort_age(lst):
    sort = []
    while lst:
        smallest = lst[0]
        for element in lst:
            if element < smallest:
                smallest = element
        a.remove(smallest)
        sort.append(smallest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for element in lst:
            if element > biggest:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    lst.sort(key=lambda x: x[1],reverse = True)
    return lst


def sort_age(lst):
    sample = lst[0]
    newlst = []
    for i in lst:
        if i[1] > sample[1]:
            newlst = [i] + newlst
        else:
            newlst += [i]
    return newlst


def sort_age(lst):
    product = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1]<smallest[1]:
                smallest = i
        lst.remove(smallest)
        product.append(smallest)
    return product


def sort_age(lst):
    new_lst=[]
    new_lst.append(lst[0])
    for i in lst[1:]:
        for j in range(len(new_lst)):
            if i[1]>new_lst[j][1] and j==0:
                new_lst.insert(0,i)
            elif i[1]<new_lst[j][-1]:
                new_lst.insert(-1,i)
            elif i[1]>new_lst[j][1]:
                new_lst.insert(j,i)
    return new_lst


def sort_age(lst):
    product = []
    while lst:
        largest = lst[0]
        for i in lst:
            if i[1]<larget[1]:
                largest = i
        lst.remove(largest)
        product.append(largest)
    return product


def sort_age(lst):
    while lsst:
        biggest = a[0]
        for element in a:
            if element > biggest:
                smallest = element
        a.remove(biggest)
        sort.append(biggest)
    return lst


def sort_age(lst):
    sort = []
    while lsst:
        biggest = a[0]
        for element in a:
            if element > biggest:
                smallest = element
        a.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        biggest = a[0]
        for element in a:
            if element > biggest:
                smallest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for element in lst:
            if element > biggest:
                smallest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[1]
        for element in lst:
            if element > biggest:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
    def for_age(lst):
        for i in range(len(lst)):
            if i == 0: continue
            else:
                while i > 0:
                    if lst[i][1] < lst[i-1][1]:
                        lst[i], lst[i-1] = lst[i-1], lst[i]
                        i -= 1
                    else: i = 0
    for_age(lst).reverse
    return lst


def sort_age(lst):
    if len(lst) == 0:
        return []
    elif len(lst) == 1:
        return lst
    else:
        mid = len(lst) // 2
        lst1 = lst[:mid]
        lst2 = lst[mid:]

        result = []
        while lst1 and lst2:
            if lst1[0][1] < lst2[0][1]:
                result.append(lst1.pop())
            else:
                result.append(lst2.pop())
        result.extend(lst1)
        result.extend(lst2)

        return result


def sort_age(lst):
    if len(lst) == 0:
        return []
    elif len(lst) == 1:
        return lst
    else:
        mid = len(lst) // 2
        lst1 = sort_age(lst[:mid])
        lst2 = sort_age(lst[mid:])

        result = []
        while lst1 and lst2:
            if lst1[0][1] < lst2[0][1]:
                result.append(lst1.pop())
            else:
                result.append(lst2.pop())
        result.extend(lst1)
        result.extend(lst2)

        return result


def sort_age(lst):
    if len(lst) == 0:
        return []
    elif len(lst) == 1:
        return lst
    else:
        mid = len(lst) // 2
        lst1 = sort_age(lst[:mid])
        lst2 = sort_age(lst[mid:])

        result = []
        while lst1 and lst2:
            if lst1[0][1] < lst2[0][1]:
                result.append(lst2.pop())
            else:
                result.append(lst1.pop())
        result.extend(lst1)
        result.extend(lst2)

        return result


def sort_age(lst):
    a=lst
    sort=[]
    while a:
        smallest=a[0]
        for element in a:
            if element[1]<smallest[1]:
                smallest=element
    a.remove(smallest)
    sort.append(smallest)
    return sort


def sort_age(lst):
    a=lst
    sort=[]
    while a:
        smallest=a[0]
        for element in a:
            if element[1]<smallest[1]:
                smallest=element
        a.remove(smallest)
        sort.append(smallest)
        sort.reverse
    return sort


def sort_age(lst):
    a=lst
    sort=[]
    while a:
        smallest=a[0]
        for element in a:
            if element[1]<smallest[1]:
                smallest=element
        a.remove(smallest)
        sort.append(smallest)
        sort.reverse()
    return sort


def sort_age(lst):
    lst.sort(key=lambda x: x[1], reverse=True)
    return lst


def sort_age(lst):
    l = len(lst)
    for i in range(l):
        largest = lst[i]
        for j in range(i+1,l):
            if lst[j][1] > largest[1]:
                largest = lst[j] #assign new largest value
                lst[i],lst[j] = lst[j],lst[j] #swap positions if larger
    return lst


def sort_age(lst):
	lst.sort(key=lambda x: x[1],reverse=True)
	print(lst)


def sort_age(lst):
    if lst==[]:
        return []
    sort=[]
    while lst:
        largest = lst[0]
        for i in lst:
            if i > largest:
                largest = i
        lst.remove(largest)
        sort.append(largest)
    return sort
    pass


def sort_age(lst):

    sort_lst = []

    while lst:
        smallest = lst[0]
        for element in lst:
            if element[1] < smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort_lst.append(smallest)
    return sort_lst.reverse()


def sort_age(lst):
    lst.sort(key = lambda x: x[1], reverse = True)
    return lst


def sort_age(lst):
    return lst.sort(key = lambda x: x[1], reverse = True)


def sort_age(lst):
    result = [lst[0]]
    for i in lst[1:]:
        if i[1] > result[0][1]:
            result.insert(0, i)
        elif i[1] < result[-1][1]:
            result.append(i)
        else:
            for j in range(len(result) - 1):
                if i[1] < result[j][1] and i[1] > result[j+1][1]:
                    result.insert(j, i)
    return result


def sort_age(lst):
    result = [lst[0]]
    for i in lst[1:]:
        if i[1] > result[0][1]:
            result.insert(0, i)
        elif i[1] < result[-1][1]:
            result.append(i)
        else:
            for j in range(len(result) - 1):
                if i[1] < result[j][1] and i[1] > result[j+1][1]:
                    result.insert(j+1, i)
    return result


def sort_age(lst):
    output = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallsest[1]:
                smallest = i
        lst.remove(i)
        output.append(i)
    return output


def sort_age(lst):
    output = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(i)
        output.append(i)
    return output


def sort_age(lst):
    output = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(smallest)
        output.append(smallest)
    return output


def sort_age(lst):
    return lst.sort(key=lambda x: x[1], reverse=True)


def sort_age(lst):
    final = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(smallest)
        final.append(smallest)
    print(lst)


def sort_age(lst):
    final = []
    while lst:
        biggest = lst[0]
        for i in lst:
            if i[1] > biggest[1]:
                biggest = i
        lst.remove(biggest)
        final.append(biggest)
        print(final)


def sort_age(lst):
    newlst=[]
    while lst:
        oldest = lst[0][1] #first age
        for person in lst:
            if person[1]>oldest:
                oldest=person[1]
                newlst.append(person)
                lst.remove(person)
        newlst.append(lst[0])
        lst.remove(lst[0])
    return newlst


def sort_age(lst):
    newlst = []
    while lst:
        current = lst[0]
        for element in lst:
            if element[1] < current[1]:
                current = element
        newlst += current
        lst.remove(current)
    return newlst


def sort_age(lst):
    newlst = []
    while lst:
        current = lst[0]
        for element in lst:
            if element[1] < current[1]:
                current = element
        newlst += (current,)
        lst.remove(current)
    return newlst


def sort_age(lst):
    result = []
    while lst:
        oldest = lst[0]
        for people in lst:
            if people[1] > oldest[1]:
                oldest = people
        lst.remove(oldest)
        result += (oldest,)


def sort_age(lst):
    # Fill in your code here
    new_lst = []
    while lst:
        for i in range(len(lst)):
            oldest = lst[0]
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)

    return new_lst


def sort_age(lst):
    arranged = []
    while lst:
        oldest = lst[0]
        for person in lst:
            if person > oldest:
                oldest = person
        lst.remove(oldest)
        arranged.append(oldest)
    return arranged
    pass


def sort_age(lst):
    lst.sort(key = lambda x:x[1], reverse = True)
    return lst


def sort_age(lst):
    a = []
    b = []
    n = len(lst)
    for i in range(n):
        age = lst[i][1]
        a += [age]
        a.sort()
        a.reverse()
    for j in range(n):
        for k in range(n):
            if a[j] == lst[k][1]:
                b += [lst[k]]
            else:
                continue
    return b


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for element in lst:
            if element > biggest:
                biggest = element
        lst.remove(biggest)
        sort.append(biggest)
    return sort


def sort_age(lst):
	lst.sort(key = lambda x: x[1], reverse = True)
	return lst


def sort_age(lst):
    final=[]
    while lst:
        old=lst[0]
        for i in lst:
            if old[1]<i[1]:
                old=i
            final.append(old)
            lst.remove(old)
    return final


def sort_age(lst):
    final=[]
    while lst:
        old=lst[0]
        for i in lst:
            if old[1]<i[1]:
                old=i
            lst.remove(old)
            final.append(old)
    return final


def sort_age(lst):
    lst.sort(key=lambda x:x[1],reverse=True)
    return lst


def sort_age(lst):
    rslt=[]
    while lst:
        smallest=a[0]
        for element in a:
            if element[1]>smallest[1]:
                smallest=element
        lst.remove(smallest)
        rslt.append(smallest)
    return rslt


def sort_age(lst):
    rslt=[]
    while lst:
        smallest=lst[0]
        for element in a:
            if element[1]>smallest[1]:
                smallest=element
        lst.remove(smallest)
        rslt.append(smallest)
    return rslt


def sort_age(lst):
    return lst.sort(key = lambda x: x[1])


def sort_age(lst):
    lst.sort(key = lambda x: x[1], reverse = True)
    return lst


def sort_age(lst):
    store = []
    oldest = lst[0]
    for i in lst[1:]:
        if i[1] > oldest[1]:
            oldest = i
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    store = []
    oldest = lst[0]
    for i in lst[1:]:
        if i[1] > oldest[1]:
            oldest = i
    lst.remove(oldest)
    sort.append(oldest)
    return sort


def sort_age(lst):
    while lst:
        oldest = lst[0]
        for i in lst[1:]:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    while lst:
        oldest = lst[0]
        for i in lst[1:]:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
        return sort


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst[1:]:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
        return sort


def sort_age(lst):
    lst = lst.sort(key = lambda x: x[1], reverse=True)
    return lst


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] >= oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    print (new_lst)


def sort_age(lst):
    return lst.sort(key=lambda x:x[1],reverse=True)


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst [0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    print(new_lst)


def sort_age(lst):
    lst.sort(key = lambda x:x[1], reverse = True)
    return lst


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    print(new_lst)


def sort_age(lst):
    holder=[]
    for x in lst:
        if holder==[]:
            holder=x
        elif x[1]>holder[1]:
            holder=x
    return holder+sort_age(lst[1:])


def sort_age(lst):
    holder=[]
    if lst==[]:
        return []
    for x in lst:
        if holder==[]:
            holder=x
        elif x[1]>holder[1]:
            holder=x
    return holder+sort_age(lst[1:])


def sort_age(lst):
    holder=[]
    if lst==[]:
        return []
    for x in lst:
        if holder==[]:
            holder=x
        elif x[1]>holder[1]:
            holder=x
    return [holder]+sort_age(lst[1:])


def sort_age(lst):
    holder=[]
    if lst==[]:
        return []
    for x in lst:
        if holder==[]:
            holder=x
        elif x[1]>holder[1]:
            holder=x
    return [holder]+sort_age(lst.remove(holder))


def sort_age(lst):
    answer = []
    for i in range(0,len(lst),-1):
        biggest = lst[i]
        for a in range(i):
            if lst[a][1] > biggest[1]:
                biggest = lst[a]
        answer += biggest
    return answer


def sort_age(lst):
    result = []
    maximum = 0
    for i in lst:
        if i[1] > maximum:
            maximum = i[1]
            result.insert(0,i)
        else:
            result.append(i)
    return result


def sort_age(lst):
	lst.sort(key=lambda tup:tup[1], reverse = True)
	return lst


def sort_age(lst):
    lst.sort(lambda x: x[1])
    return lst


def sort_age(lst):
    lst.sort(key = lambda x: x[1])
    return lst


def sort_age(lst):
    lst.sort(key = lambda x: x[1], reverse = True)
    return lst


def sort_age(lst):
    for i in range(len(lst)-1):
        while lst[i][1] > lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
    return lst


def sort_age(lst):
    for i in range(len(lst)-1):
        while lst[i][1] < lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
    return lst


def sort_age(lst):
    for i in range(len(lst)-1):
        while lst[i][1] > lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
    return lst.reverse()


def sort_age(lst):
    for i in range(len(lst)-1):
        while lst[i][1] > lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
    lst.reverse()
    return lst


def sort_age(lst):
    largest = lst[0][1]
    sort1 = []
    for i in lst:
        if i > largest:
            largest = i
            sort1.append(i)
    return sort1


def sort_age(lst):
    largest = lst[0][1]
    sort1 = []
    for i in lst:
        if i[1] > largest:
            largest = i[1]
        sort1.append(i)
    return sort1


def sort_age(lst):
    sort1 = []
    while lst:
        largest = lst[0][1]
        if i[1] > largest:
            largest = i[1]
        lst.remove(i)
        sort1.append(i)
    return sort1


def sort_age(lst):
    sort1 = []
    while lst:
        largest = lst[0][1]
        for i in lst:
            if i[1] > largest:
                largest = i[1]
        lst.remove(i)
        sort1.append(i)
    return sort1


def sort_age(lst):
    smallest =  lst[0][1]
    sort = []
    while lst:
        for k in lst:
            if k[1] < smallest:
                smallest = k[1]
        a.remove(smallest)
        sort.append(smallest)


def sort_age(lst):
    smallest =  lst[0][1]
    sort = []
    while lst:
        for k in lst:
            if k[1] < smallest:
                smallest = k[1]
                smallest_tuple = k
        lst.remove(k)
        sort.append(k)


def sort_age(lst):
    lst.sort(key=lambda x: x[1], reverse=True)
    return lst


def sort_age(lst):
    sort = []
    while lst:
        biggest = lst[0]
        for k in lst:
            if k[1] > biggest[1]:
                biggest = k
        lst.remove(biggest)
        sort.append(biggest)


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0][1]
        for i in lst:
            if i[1]>largest:
                largest = i[1]
        tpl = ()
        for j in lst:
            if j[1] == largest:
                j = tpl
        lst.remove(tpl)
        new.append(tpl)
    return new


def sort_age(lst):
    new_lst = []
    while lst:
        oldest = lst[0]
        for i in range(len(lst)):
            if lst[i][1] > oldest[1]:
                oldest = lst[i]
        lst.remove(oldest)
        new_lst.append(oldest)
    print(new_lst)


def sort_age(lst):
    lst.sort(key=lambda x:x[1],reverse=True)
    return lst


def sort_age(lst):
    # Fill in your code here
    out = [lst[0],]
    for ele in lst[1:]:
        for indx in range(len(out)):
            if out[indx] < ele:
                out.insert(indx, ele)
                break
            elif indx == len(out) - 1:
                out.append(ele)
    return out


def sort_age(lst):
    # Fill in your code here
    out = [lst[0],]
    for ele in lst[1:]:
        for indx in range(len(out)):
            if out[indx][1] < ele[1]:
                out.insert(indx, ele)
                break
            elif indx == len(out) - 1:
                out.append(ele)
    return out


def sort_age(lst):
    # Fill in your code here
    if lst == ():
        return lst

    out = [lst[0],]
    for ele in lst[1:]:
        for indx in range(len(out)):
            if out[indx][1] < ele[1]:
                out.insert(indx, ele)
                break
            elif indx == len(out) - 1:
                out.append(ele)
    return out


def sort_age(lst):
    # Fill in your code here
    lst.sort(key=lambda x : x[1], reverse=T)


def sort_age(lst):
    sort=[]
    while lst:
        biggest=lst[0]
        for element in lst:
            if element[1] > biggest[1]:
                biggest=element
        lst.remove(biggest)
        sort.append(biggest)
    sort.append(biggest)
    return sort


def sort_age(lst):
    first = lst[0][1]
    result = []
    for x in lst[1:]:
        if x[1] > first:
            result = (first,) + (x[1],)
        else:
            result = (x[1],) + (first,)
    pass


def sort_age(lst):
    first = lst[0][1]
    result = []
    for x in lst[1:]:
        if x[1] > first:
            result = (first,) + (x[1],)
        else:
            result = (x[1],) + (first,)
    return result
    pass


def sort_age(lst):
    first = lst[0]
    firstnum = lst[0][1]
    result = []
    for x in lst[1:]:
        if x[1] > firstnum:
            result = (first,) + (x,)
        else:
            result = (x,) + (first,)
    return result
    pass


def sort_age(lst):
    firstnum = lst[0][1]
    result = (lst[0],)
    for x in lst[1:]:
        if x[1] > firstnum:
            result += (x,)
        else:
            result = (x,) + result
    return result
    pass


def sort_age(lst):
    firstnum = lst[0][1]
    result = (lst[0],)
    for x in lst[1:]:
        if x[1] < firstnum:
            result += (x,)
        else:
            result = (x,) + result
    return result
    pass


def sort_age(lst):
    firstnum = lst[0][1]
    result = [lst[0],]
    for x in lst[1:]:
        if x[1] < firstnum:
            result += (x,)
        else:
            result = (x,) + result
    return result
    pass


def sort_age(lst):
    lst1=[]
    while lst:
        smallest=lst[0]
        for ele in lst:
            if ele[1]<smallest[1]:
                smallest=ele
        lst.remove(smallest)
        lst1.append(smallest)
    return lst1


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(biggest)
        sort.append(biggest)
        return sort
    # Fill in your code here


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1] > oldest[1]:
                oldest = i
        lst.remove(biggest)
        sort.append(biggest)
    return sort
    # Fill in your code here


def sort_age(lst):

    people = []

    while lst:

        i = lst[0]

        for a in lst:

            if i[1] <= a[1] :

                i = a

        lst.remove(i)
        final.append(i)

    return final


def sort_age(lst):

    people = []

    while lst:

        i = lst[0]

        for a in lst:

            if a[1] >= i[1] :

                i = a

        lst.remove(i)

        final.append(i)

    return final


def sort_age(lst):

    people = []

    while lst:

        i = lst[0]

        for a in lst:

            if a[1] >= i[1] :

                i = a

        lst.remove(i)

        people.append(i)

    return final


def sort(lst):
    for i in range(len(lst)-1):
        if lst[i][1] > lst[i+1][1]:
            temp = lst[i]
            del lst[i]
            lst += [temp]
        else:
            continue
    return lst

def sort_age(lst):
    oldlist = tuple(lst)
    if tuple(sort(lst)) == oldlist:
        return lst
    else:
        sort(lst)
        return sort_age(lst)


def sort_age(lst):
    lst.sort(key= lambda x: x[1], reverse = True)
    return lst


def sort_age(lst):
    while lst:
        smallest = lst[0]
    for e in lst[1:]:
        if e[1]<smallest:
            smallest = e[1]
    lst.remove(smallest)
    lst.append(smallest)
    return lst


def sort_age(lst):
    if lst == []:
        return new
    new = []
    small = lst[0][1]
    for i in range(1,len(lst)):
        if lst[i][1]<small:
            small = lst[i][1]
    new.append(small)
    lst.remove(small)
    sort_age(lst)


def sort_age(lst):
    if lst == []:
        return new
    new = []
    small = lst[0][1]
    for i in range(1,len(lst)):
        if lst[i][1]<small:
            small = lst[i][1]
    new.append(small)
    lst.remove(small)
    return sort_age(lst)


def sort_age(lst):
    a = lst
    sort = []
    smallest = a[0][1]
    while   a: # a is not []
        for element in  a:
            if element[1] > smallest:
                smallest = element
        a.remove(smallest)
        sort.append(smallest)

    pass


def sort_age(lst):
    if len(lst) == 1:
        return lst
    else:
        new_list = []
        while lst:
            minimum = lst[0]
            for i in lst:
                if i[1] < minimum[1]:
                    minimum = x
            new_list.append(minimum)
            lst.remove(minimum)
        return new_list


def sort_age(lst):
    while lst: # a is not []
        smallest = lst[0]
        for element in lst:
            if element[1] < smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort.append(smallest)


def sort_age(lst):
    sort_list = []
    while lst: # a is not []
        smallest = lst[0]
        for element in lst:
            if element[1] < smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort_list.append(smallest)


def sort_age(lst):
    sort_list = []
    while lst: # a is not []
        smallest = lst[0]
        for element in lst:
            if element[1] < smallest[1]:
                smallest = element
        lst.remove(smallest)
        sort_list.append(smallest)
    return sort_list


def sort_age(lst):
    sort_list = []
    while lst: # a is not []
        biggest = lst[0]
        for element in lst:
            if element[1] > smallest[1]:
                biggest = element
        lst.remove(biggest)
        sort_list.append(biggest)
    return sort_list


def sort_age(lst):
    sort = []
    while lst:
        oldest = lst[0]
        for i in lst:
            if i[1]<oldest[1]:
                oldest = i
        lst.remove(oldest)
        sort.append(oldest)
    return sort


def sort_age(lst):
    males = []
    females = []
    for i in lst:
        if lst[0][0] == "M":
            males = males + [lst[0],]
        elif lst[0][0] == "F":
            females = females + [lst[0],]
    return merge_sort(males) + merge_sort(females)

def merge(left, right):
    results = []
    while left and right:
        if left[0][0] < right[0][0]:
            results.append(left,pop(0))
        else:
            results.append(right.pop(0))
    results.extend(left)
    results.extend(right)
    return results

def merge_sort(lst):
    if len(lst) < 2:
        return lst
    mid = len(lst) // 2
    left = merge_sort(lst[:mid])
    right = merge_sort(lst[mid:])
    return merge(left, right)


def sort_age(lst):
    males = []
    females = []
    while len(lst) > 0:
        if lst[0][0] == "M":
            males = males + [lst[0],]
        elif lst[0][0] == "F":
            females = females + [lst[0],]
        lst = lst[1:]
    return merge(merge_sort(males), merge_sort(females))

def merge(left, right):
    results = []
    while left and right:
        if left[0][0] < right[0][0]:
            results.append(left.pop(0))
        else:
            results.append(right.pop(0))
    results.extend(left)
    results.extend(right)
    return results

def merge_sort(lst):
    if len(lst) < 2:
        return lst
    mid = len(lst) // 2
    left = merge_sort(lst[:mid])
    right = merge_sort(lst[mid:])
    return merge(left, right)


def sort_age(lst):
    males, females = [], []
    for i in lst:
        if i[0] == "M":
            males = males + [lst[0],]
        elif i[0] == "F":
            females = females + [lst[0],]
        lst = lst[1:]
    return merge(merge_sort(males), merge_sort(females))

def merge(left, right):
    results = []
    while left and right:
        if left[0] > right[0]:
            results.append(left.pop(0))
        else:
            results.append(right.pop(0))
    results.extend(left)
    results.extend(right)
    return results

def merge_sort(lst):
    if len(lst) < 2:
        return lst
    mid = len(lst) // 2
    left = merge_sort(lst[:mid])
    right = merge_sort(lst[mid:])
    return merge(left, right)


def sort_age(lst):
    youngest = lst[0][1]
    sorted = []
    while lst:
        for elem in lst:
            if elem[1] < youngest:
                youngest = elem[1]
        lst.remove(youngest)
        sorted.append(youngest)
    return sorted


def sort_age(lst):
    sorted = []
    while lst:
        youngest = lst[0]
        for elem in lst:
            if elem[1] < youngest[1]:
                youngest = elem
        print(youngest)
        lst.remove(youngest)
        sorted.append(youngest)
    return sorted


def sort_age(lst):
    i=0
    while i+1<len(lst):
        if i[1]<i+1[1]:
            lst.pop(i)
            lst.extend(i)
        else:
            i+=1
    return lst


def sort_age(lst):
    new = []
    while lst:
        small = lst[0][1]
        name =lst[0][0]
        for ele in lst:
            if ele[1]<small:
                small = ele[1]
                name = ele[0]
        new.append((name,small))
        lst.remove((name,small))
    return new


def sort_age(lst):
    i=0
    while i+1<len(lst):
        if lst[i][1]<lst[i+1][1]:
            lst.extend([lst[i]])
            lst.pop([lst[i]])
        else:
            i+=1
    return lst


def sort_age(lst):
    new = []
    while lst:
        small = lst[0][1]
        name =lst[0][0]
        for ele in lst:
            if ele[1]<small:
                small = ele[1]
                name = ele[0]
        new.append((name,small))
        lst.remove((name,small))
    return new.reverse


def sort_age(lst):
    i=0
    while i+1<len(lst):
        if lst[i][1]<lst[i+1][1]:
            lst.extend([lst[i]])
            lst.pop(lst[i])
        else:
            i+=1
    return lst


def sort_age(lst):
    return lst.sort(key = lambda x:x[1])


def sort_age(lst):
    new = []
    while lst:
        small = lst[0][1]
        name =lst[0][0]
        for ele in lst:
            if ele[1]>small:
                small = ele[1]
                name = ele[0]
        new.append((name,small))
        lst.remove((name,small))
    return new.reverse


def sort_age(lst):
    new = []
    while lst:
        curr = lst[0][1]
        for i in range(lst(old)):
            if lst[i][1]<curr:
                curr = lst[i][1]
                counter = i
        lst.remove(counter)
        new.append(counter)

    return new


def sort_age(lst):
    new = []
    while lst:
        curr = lst[0]
        for i in lst:
            if i[1]<curr[1]:
                curr = i
        lst.remove(i)
        new.append(i)

    return new


def sort_age(lst):
	lst.sort(key = lambda x:x[1], reverse=True)
	print (lst)


def sort_age(lst):
    i=0
    while i+1<len(lst):
        if lst[i][1]<lst[i+1][1]:
            lst.extend([lst[i]])
            del lst[i]
        else:
            i+=1
    return lst


def sort_age(lst):
    return lst.sort(key = lambda x: x[1], reverse = True)


def sort_age(lst):
    lst.sort(key = lambda x: x[1], reverse = True)
    return lst


def sort_age(lst):
    lst.sort(key=lambda x:x[1],reverse=True)
    return lst


def sort_age(lst):
    lst = ()
    for i in lst:
        if lst[i][1]<lst[0][1]:
            lst += lst[0]
        else:
            lst += lst[i]
    return lst


def sort_age(lst):
    lst.sort(key = lambda x: x[1])


def sort_age(lst):
    sort = [] #empty list
    while lst:
        largest = lst[0] #let the first element be the smallest first
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.removal(largest)
        sort.append(a)
    return sort


def sort_age(lst):
    sort = [] #empty list
    while lst:
        largest = lst[0] #let the first element be the smallest first
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.removal(largest)
        sort.append(largest)
    return sort


def sort_age(lst):
    sortt = [] #empty list
    while lst:
        largest = lst[0] #let the first element be the largest first
        for i in lst:
            if i[1] > largest[1]:
                largest = i
        lst.remove(largest)
        sortt.append(largest)
    return sort


def sort_age(lst):
    sorted_lst = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(smallest)
        sorted_lst.append(smallest)
    return sorted_lst


def sort_age(lst):
    sorted_lst = []
    while lst:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest = i
        lst.remove(smallest)
        sorted_lst.append(smallest)
    return sorted_lst.reverse


def sort_age(lst):
    lst.sort(lambda x: x[1])
    return lst


def sort_age(lst):
    sort=[]
    while lst:
        smallest = lst[0][1]
        for i in range (len(lst)):
            if lst[i][1] < smallest:
                smallest = lst[i][1]
        a.remove(smallest)
        sort.append(smallest)
        sort.reverse(smallest)
        return sort


def sort_age(lst):
    sort=[]
    while lst:
        smallest = lst[0][1]
        for i in range (len(lst)):
            if lst[i][1] < smallest:
                smallest = lst[i][1]
        lst.remove(smallest)
        sort.append(smallest)
        sort.reverse(smallest)
        return sort


def sort_age(lst):
    sort=[]
    while lst:
        smallest = lst[0][1]
        for i in range (1,len(lst)):
            if lst[i][1] < smallest:
                smallest = lst[i][1]
        lst.remove(smallest)
        sort.append(smallest)
        sort.reverse(smallest)
        return sort


def sort_age(lst):
    newlst = []
    ages = []
    for i in lst:
        ages.append(i[1])
    ages.sort()
    for x in ages[::-1]:
        for i in lst:
            if i[1] == x:
                newlst.append(i)
    return newlst


def sort_age(lst):
	lst.sort(key = lambda x: x[1], reverse = True)
	return lst


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0][1]
        for item in a:
            if item[1] >largest:
                largest = item
        a.remove(largest)
        sort.append(largest)
        print(sort)# Fill in your code here


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0]
        for item in a:
            if item[1] >largest[1]:
                largest = item
        a.remove(largest)
        sort.append(largest)
        print(a)
        print(sort)# Fill in your code here


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0]
        for item in a:
            if item[1] >largest[1]:
                largest = item
        a.remove(largest)
        sort.append(largest)

        print(sort)# Fill in your code here


def sort_age(lst):
    lst.sort(key = lambda x: x[1], reverse = True)
    print(lst)


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0]
        for item in a:
            if item[1] >largest[1]:
                largest = item
        a.remove(largest)
        sort.append(largest)

        return sort# Fill in your code here


def sort_age(lst):
    a = lst
    sort = []
    while a:
        largest = a[0]
        for item in a:
            if item[1] >largest[1]:
                largest = item
        a.remove(largest)
        sort.append(largest)

    print(sort)# Fill in your code here


def sort_age(lst):
    new = []
    while lst:
        eldest = lst[0]
        for i in lst:
            if i > eldest:
                eldest = i
        lst.remove(eldest)
        new.append(eldest)
    return new


def sort_age(lst):
    return lst.sort(key=lambda x: x[1], reverse=True)


def sort_age(lst):
    lst.sort(key=lambda x: x[1], reverse=True)
    return lst


def sort_age(lst):
    sort = [ ]
    while lst: # a is not [ ]
        biggest = lst[0]
    for element in lst:
        if element[1] > biggest[1]:
            biggest = element
    lst.remove(biggest)
    sort.append(biggest)
    return sort


def sort_age(lst):
    sort = []
    while lst: # a is not [ ]
        biggest = lst[0]
    for element in lst:
        if element[1] > biggest[1]:
            biggest = element
    lst.remove(biggest)
    sort.append(biggest)
    return sort


def sort_age(lst):
    lst.sort()
    lst.reverse()
    return lst
    pass


def sort_age(lst):
    lst.sort(key=lambda x: x[1], reverse=True)
    return lst
    pass


def sort_age(lst):
    biggest = lst[0][1]
    for i in range(len(lst)):
        if lst[0][1]<lst[i][1]:
            biggest = lst[i][1]
            continue
        else:
            biggest = lst[0][1]
    return [(biggest),] + sort_age(lst[1:len(lst)])
    pass


def sort_age(lst):
    new = []
    while lst:
        smallest = lst[0][1]
        for i in lst:
            if i[1] < smallest:
                smallest = i[1]
        lst.remove(smallest)
        new.append(smallest)
    return new


def sort_age(lst):
    new = []
    while lst:
        largest = lst[0][1]
        for i in lst:
            if i[1] > largest:
                largest = i[1]
        lst.remove(i)
        new.append(i)
    return new


def sort_age(lst):
    new_lst = []
    for i in range(len(lst)):
        if lst[i][1]< lst[i+1][1]:
            new_lst.append(lst[i])
    lst.reverse()
    return lst

    pass


def sort_age(lst):
    new_lst = [()]
    for i in range(len(lst)):
        if lst[i][1]< lst[i+1][1]:
            new_lst.append(lst[i])
    lst.reverse()
    return lst

    pass


def sort_age(lst):
    new_lst = []
    for i in range(len(lst)):
        if lst[i][1]> lst[i+1][1]:
            new_lst.append(lst[i])
    return lst

    pass


def sort_age(lst):
    lst.sort(key=lambda x:x[1],reverse=True)
    return lst


def sort_age(lst):
    agelist = [lst[0],]
    for i in lst:
        if i[1] > agelist[0][1]:
            agelist.insert(0, i)
        elif i[1] < agelist[len(agelist)-1][1]:
            agelist.insert(len(agelist), i)
        else:
            for x in range(0,len(agelist)):
                if agelist[x][1]< i[1] < agelist[x+1][1]:
                    agelist.insert(x+1, i)
    return agelist


def sort_age(lst):
    decoy = []
    decoy2 = []
    final = []
    for i in lst:
        decoy.append(i[1])
    while decoy != []:
        decoy2.append(min(decoy))
        decoy.remove(min(decoy))
    for i in decoy2:
        for j in lst:
            if i == j[1]:
                final.append(j)
    return final


def sort_age(lst):
    sort = []
    while len(lst) > 0:
        smallest = lst[0]
        for i in lst:
            if i[1] < smallest[1]:
                smallest[1] = i[1]

        lst.remove(smallest)
        sort.append(smallest)
    return sort


def sort_age(lst):
    agelist = [lst[0],]
    for i in range(1,len(lst)):
        if lst[i][1] > agelist[0][1]:
            agelist.insert(0, lst[i])
        elif lst[i][1] < agelist[len(agelist)-1][1]:
            agelist.insert(len(agelist), lst[i])
        else:
            for x in range(0,len(agelist)):
                if agelist[x][1]> lst[i][1] > agelist[x+1][1]:
                    agelist.insert(x+1, lst[i])
                break
    return agelist


def sort_age(lst):
    if len(lst)==1:
        return lst
    else:
        used_lst=lst.copy()
        ages=()
        for i in lst:
            ages+=(i[1],)
        for i in lst:
            if i[1]==max(ages):
                new_lst=[i]
                used_lst.remove(i)
        return new_lst+sort_age(used_lst)


def sort_age(lst):
    agelist = [lst[0],]
    for i in range(1,len(lst)):
        if lst[i][1] > agelist[0][1]:
            agelist.insert(0, lst[i])
        elif lst[i][1] < agelist[len(agelist)-1][1]:
            agelist.insert(len(agelist), lst[i])
        else:
            for x in range(0,len(agelist)):
                if agelist[x][1]> lst[i][1] > agelist[x+1][1]:
                    agelist.insert(x+1, lst[i])
                    break
    return agelist


def merge(one,two):
    new_tup = []
    while left and right:
        if one[0][1] < two[0][1]:
            new_tup.append(one.pop(0))
        else:
            new_tup.append(two.pop(0))
    return new_tup

def sort_age(lst):
    n = len(lst)
    if n <2:
        return lst
    left = lst[:n/2]
    right = lst[n/2:]
    return merge(left,right)


def merge(one,two):
    new_tup = []
    while one and two:
        if one[0][1] < two[0][1]:
            new_tup.append(one.pop(0))
        else:
            new_tup.append(two.pop(0))
    return new_tup

def sort_age(lst):
    n = len(lst)
    if n <2:
        return lst
    left = lst[:n/2]
    right = lst[n/2:]
    return merge(left,right)


def sort_age(lst):
    sort = []
    while lst:
        smallest = lst[0]
        for element in a:
            if element[1] < smallest[1]:
                smallest = element
            lst.remove(smallest)
            sort.append(smallest)

    pass


def sort_age(lst):
    return lst.sort(key=lambda x: x[1], reverse=True)