id
stringlengths
35
39
content
stringlengths
44
3.85k
max_stars_repo_path
stringlengths
52
57
refactory_data_question_4_correct_4_292
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
./refactory/data/question_4/code/correct/correct_4_292.py
refactory_data_question_4_correct_4_297
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
./refactory/data/question_4/code/correct/correct_4_297.py
refactory_data_question_4_correct_4_246
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
./refactory/data/question_4/code/correct/correct_4_246.py
refactory_data_question_4_correct_4_078
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
./refactory/data/question_4/code/correct/correct_4_078.py
refactory_data_question_4_correct_4_358
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
./refactory/data/question_4/code/correct/correct_4_358.py
refactory_data_question_4_correct_4_097
def sort_age(lst): output = [] while lst: largest = lst[0] for i in lst: if i[1] > largest[1]: largest = i lst.remove(largest) output.append(largest) return output
./refactory/data/question_4/code/correct/correct_4_097.py
refactory_data_question_4_correct_4_341
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
./refactory/data/question_4/code/correct/correct_4_341.py
refactory_data_question_4_correct_4_108
def sort_age(lst): newlst=[] while lst: oldest = lst[0][1] #first age for person in lst: if person[1]>oldest: oldest=person[1] for person in lst: if person[1]==oldest: newlst.append(person) lst.remove(person) return newlst
./refactory/data/question_4/code/correct/correct_4_108.py
refactory_data_question_4_correct_4_370
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
./refactory/data/question_4/code/correct/correct_4_370.py
refactory_data_question_4_correct_4_380
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
./refactory/data/question_4/code/correct/correct_4_380.py
refactory_data_question_4_correct_4_171
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
./refactory/data/question_4/code/correct/correct_4_171.py
refactory_data_question_4_correct_4_133
def sort_age(lst): result=[] def lame(lst): loser=0 list_of_numbers=[] x=len(lst) if lst==[]: return result for i in range(x): list_of_numbers+=[lst[i][1]] y=max(list_of_numbers) for i in lst: if i[1]==y: loser=i result.append(loser) lst.remove(loser) return lame(lst) return lame(lst)
./refactory/data/question_4/code/correct/correct_4_133.py
refactory_data_question_4_correct_4_154
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)
./refactory/data/question_4/code/correct/correct_4_154.py
refactory_data_question_4_correct_4_055
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(0)) else: result.append(lst1.pop(0)) result.extend(lst1) result.extend(lst2) return result
./refactory/data/question_4/code/correct/correct_4_055.py
refactory_data_question_4_correct_4_022
def sort_age(lst): result = [] while lst: biggest = lst[0] for element in lst: if element[1] > biggest[1]: biggest = element lst.remove(biggest) result.append(biggest) return result
./refactory/data/question_4/code/correct/correct_4_022.py
refactory_data_question_4_correct_4_170
def sort_age(lst): new = [] while lst: Max = max(lst,key = lambda x : x[1]) new.append(Max) lst.remove(Max) return new
./refactory/data/question_4/code/correct/correct_4_170.py
refactory_data_question_4_correct_4_138
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
./refactory/data/question_4/code/correct/correct_4_138.py
refactory_data_question_4_correct_4_284
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)
./refactory/data/question_4/code/correct/correct_4_284.py
refactory_data_question_4_correct_4_365
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
./refactory/data/question_4/code/correct/correct_4_365.py
refactory_data_question_4_correct_4_185
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
./refactory/data/question_4/code/correct/correct_4_185.py
refactory_data_question_4_correct_4_116
def sort_age(lst): # Fill in your code here a = [] for i in lst: if a ==[]: a.append(i) continue else: for k in range(0,len(lst)): if i[1]>a[0][1]: a.insert(0,i) break elif a[-1][1]>i[1]: a.insert(len(lst),i) break elif i[1] > a[k+1][1] and i[1]<a[k][1]: a.insert(k+1,i) break return a
./refactory/data/question_4/code/correct/correct_4_116.py
refactory_data_question_4_correct_4_120
def sort_age(lst): arranged = [] while lst: oldest = lst[0] for person in lst: if person[1] > oldest[1]: oldest = person lst.remove(oldest) arranged.append(oldest) return arranged pass
./refactory/data/question_4/code/correct/correct_4_120.py
refactory_data_question_4_correct_4_176
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
./refactory/data/question_4/code/correct/correct_4_176.py
refactory_data_question_4_correct_4_320
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
./refactory/data/question_4/code/correct/correct_4_320.py
refactory_data_question_4_correct_4_164
def sort_age(lst): n = len(lst)-1 for i in range(0,n): 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
./refactory/data/question_4/code/correct/correct_4_164.py
refactory_data_question_4_correct_4_172
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
./refactory/data/question_4/code/correct/correct_4_172.py
refactory_data_question_4_correct_4_174
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 # Fill in your code here
./refactory/data/question_4/code/correct/correct_4_174.py
refactory_data_question_4_correct_4_344
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
./refactory/data/question_4/code/correct/correct_4_344.py
refactory_data_question_4_correct_4_073
def sort_age(lst): new=[] while lst !=[]: big=lst[0] for i in lst: if i[1]>big[1]: big=i lst.remove(big) new.append(big) return new
./refactory/data/question_4/code/correct/correct_4_073.py
refactory_data_question_4_correct_4_237
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)
./refactory/data/question_4/code/correct/correct_4_237.py
refactory_data_question_4_correct_4_326
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
./refactory/data/question_4/code/correct/correct_4_326.py
refactory_data_question_4_correct_4_121
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
./refactory/data/question_4/code/correct/correct_4_121.py
refactory_data_question_4_correct_4_089
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
./refactory/data/question_4/code/correct/correct_4_089.py
refactory_data_question_4_correct_4_107
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: tpl = j lst.remove(tpl) new.append(tpl) return new
./refactory/data/question_4/code/correct/correct_4_107.py
refactory_data_question_4_correct_4_338
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
./refactory/data/question_4/code/correct/correct_4_338.py
refactory_data_question_4_correct_4_381
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
./refactory/data/question_4/code/correct/correct_4_381.py
refactory_data_question_4_correct_4_044
def sort_age(lst): tmp = [] ages = [x[1] for x in lst] while len(ages) > 0: age = max(ages) for x in lst: if x[1] == age: tmp.append(x) ages.remove(age) continue return tmp
./refactory/data/question_4/code/correct/correct_4_044.py
refactory_data_question_4_correct_4_295
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
./refactory/data/question_4/code/correct/correct_4_295.py
refactory_data_question_4_correct_4_027
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
./refactory/data/question_4/code/correct/correct_4_027.py
refactory_data_question_4_correct_4_026
def sort_age(lst): sort = [] while lst: oldest = lst[0] for person in lst: if person[1] >= oldest[1]: oldest = person lst.remove(oldest) sort.append(oldest) return sort
./refactory/data/question_4/code/correct/correct_4_026.py
refactory_data_question_4_correct_4_058
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
./refactory/data/question_4/code/correct/correct_4_058.py
refactory_data_question_4_correct_4_004
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
./refactory/data/question_4/code/correct/correct_4_004.py
refactory_data_question_4_correct_4_419
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
./refactory/data/question_4/code/correct/correct_4_419.py
refactory_data_question_4_correct_4_257
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
./refactory/data/question_4/code/correct/correct_4_257.py
refactory_data_question_4_correct_4_066
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
./refactory/data/question_4/code/correct/correct_4_066.py
refactory_data_question_4_correct_4_042
def sort_age(lst): old_lst = lst new_lst = [] while old_lst: largest = old_lst[0][1] remove = old_lst[0] for i in lst: if i[1] > largest: largest = i[1] remove = i old_lst.remove(remove) new_lst.append(remove) return new_lst
./refactory/data/question_4/code/correct/correct_4_042.py
refactory_data_question_4_correct_4_313
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
./refactory/data/question_4/code/correct/correct_4_313.py
refactory_data_question_4_correct_4_340
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
./refactory/data/question_4/code/correct/correct_4_340.py
refactory_data_question_4_correct_4_404
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
./refactory/data/question_4/code/correct/correct_4_404.py
refactory_data_question_4_correct_4_180
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
./refactory/data/question_4/code/correct/correct_4_180.py
refactory_data_question_4_correct_4_349
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
./refactory/data/question_4/code/correct/correct_4_349.py
refactory_data_question_4_correct_4_413
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
./refactory/data/question_4/code/correct/correct_4_413.py
refactory_data_question_4_correct_4_090
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
./refactory/data/question_4/code/correct/correct_4_090.py
refactory_data_question_4_correct_4_408
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
./refactory/data/question_4/code/correct/correct_4_408.py
refactory_data_question_4_correct_4_151
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
./refactory/data/question_4/code/correct/correct_4_151.py
refactory_data_question_4_correct_4_291
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
./refactory/data/question_4/code/correct/correct_4_291.py
refactory_data_question_4_correct_4_279
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)
./refactory/data/question_4/code/correct/correct_4_279.py
refactory_data_question_4_correct_4_202
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
./refactory/data/question_4/code/correct/correct_4_202.py
refactory_data_question_4_correct_4_057
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
./refactory/data/question_4/code/correct/correct_4_057.py
refactory_data_question_4_correct_4_018
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(0)) else: result.append(lst1.pop(0)) result.extend(lst1) result.extend(lst2) return result
./refactory/data/question_4/code/correct/correct_4_018.py
refactory_data_question_4_correct_4_165
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
./refactory/data/question_4/code/correct/correct_4_165.py
refactory_data_question_4_correct_4_396
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]
./refactory/data/question_4/code/correct/correct_4_396.py
refactory_data_question_4_correct_4_034
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)
./refactory/data/question_4/code/correct/correct_4_034.py
refactory_data_question_4_correct_4_012
def quicksort(lst, f): if len(lst) <= 1: return lst pivot_ind = len(lst)//2 pivot = lst[pivot_ind] flist, blist = [], [] for i in range(len(lst)): if i == pivot_ind: continue if f(lst[i]) <= f(pivot): flist.append(lst[i]) else: blist.append(lst[i]) finalsort = quicksort(flist, f) + [pivot] + quicksort(blist, f) return finalsort def sort_age(lst): return quicksort(lst, lambda x: x[1])[::-1]
./refactory/data/question_4/code/correct/correct_4_012.py
refactory_data_question_4_correct_4_285
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
./refactory/data/question_4/code/correct/correct_4_285.py
refactory_data_question_4_correct_4_159
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: tpl = j lst.remove(tpl) new.append(tpl) return new
./refactory/data/question_4/code/correct/correct_4_159.py
refactory_data_question_4_correct_4_063
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
./refactory/data/question_4/code/correct/correct_4_063.py
refactory_data_question_4_correct_4_216
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
./refactory/data/question_4/code/correct/correct_4_216.py
refactory_data_question_4_correct_4_056
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
./refactory/data/question_4/code/correct/correct_4_056.py
refactory_data_question_4_correct_4_343
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
./refactory/data/question_4/code/correct/correct_4_343.py
refactory_data_question_4_correct_4_011
def sort_age(lst): answer = [] while lst: largest = lst[0] for entry in lst: if entry[1] > largest[1]: largest = entry answer.append(largest) lst.remove(largest) return answer
./refactory/data/question_4/code/correct/correct_4_011.py
refactory_data_question_4_correct_4_218
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
./refactory/data/question_4/code/correct/correct_4_218.py
refactory_data_question_4_correct_4_083
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
./refactory/data/question_4/code/correct/correct_4_083.py
refactory_data_question_4_correct_4_052
def sort_age(lst): # Fill in your code here 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
./refactory/data/question_4/code/correct/correct_4_052.py
refactory_data_question_4_correct_4_278
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)
./refactory/data/question_4/code/correct/correct_4_278.py
refactory_data_question_4_correct_4_033
def sort_age(lst): tmp = [] ages = [x[1] for x in lst] while len(ages) > 0: age = max(ages) for x in lst: if x[1] == age: tmp.append(x) ages.remove(age) continue return tmp
./refactory/data/question_4/code/correct/correct_4_033.py
refactory_data_question_4_correct_4_200
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
./refactory/data/question_4/code/correct/correct_4_200.py
refactory_data_question_4_correct_4_221
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)
./refactory/data/question_4/code/correct/correct_4_221.py
refactory_data_question_4_correct_4_367
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
./refactory/data/question_4/code/correct/correct_4_367.py
refactory_data_question_4_correct_4_187
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)
./refactory/data/question_4/code/correct/correct_4_187.py
refactory_data_question_4_correct_4_125
def sort_age(lst): newlst = [] while lst: oldest = lst[0] for element in lst: if element[1] > oldest[1]: oldest = element lst.remove(oldest) newlst.append(oldest) return newlst
./refactory/data/question_4/code/correct/correct_4_125.py
refactory_data_question_4_correct_4_299
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
./refactory/data/question_4/code/correct/correct_4_299.py
refactory_data_question_4_correct_4_377
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
./refactory/data/question_4/code/correct/correct_4_377.py
refactory_data_question_4_correct_4_061
def sort_age(lst): sort_lst = [] while lst: smallest = lst[0] for e in lst: if e[1] < smallest[1]: smallest = e lst.remove(smallest) sort_lst.append(smallest) return sort_lst[::-1]
./refactory/data/question_4/code/correct/correct_4_061.py
refactory_data_question_4_correct_4_047
def sort_age(lst): product = [] while lst: largest = lst[0] for i in lst: if i[1]>largest[1]: largest = i lst.remove(largest) product.append(largest) return product
./refactory/data/question_4/code/correct/correct_4_047.py
refactory_data_question_4_correct_4_369
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
./refactory/data/question_4/code/correct/correct_4_369.py
refactory_data_question_4_correct_4_330
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
./refactory/data/question_4/code/correct/correct_4_330.py
refactory_data_question_4_correct_4_302
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
./refactory/data/question_4/code/correct/correct_4_302.py
refactory_data_question_4_correct_4_203
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
./refactory/data/question_4/code/correct/correct_4_203.py
refactory_data_question_4_correct_4_375
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
./refactory/data/question_4/code/correct/correct_4_375.py
refactory_data_question_4_correct_4_031
def sort_age(lst): result = [] while lst != []: largest_tup = lst[0] 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
./refactory/data/question_4/code/correct/correct_4_031.py
refactory_data_question_4_correct_4_029
def sort_age(lst): new_lst = [] while lst: max_age = lst[0] for tpl in lst: if tpl[1] > max_age[1]: max_age = tpl new_lst.append(max_age) lst.remove(max_age) return new_lst
./refactory/data/question_4/code/correct/correct_4_029.py
refactory_data_question_4_correct_4_406
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
./refactory/data/question_4/code/correct/correct_4_406.py
refactory_data_question_4_correct_4_095
def sort_age(lst): sort_lst = [] while lst: smallest = lst[0] for e in lst: if e[1] < smallest[1]: smallest = e lst.remove(smallest) sort_lst.append(smallest) return sort_lst[::-1]
./refactory/data/question_4/code/correct/correct_4_095.py
refactory_data_question_4_correct_4_213
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
./refactory/data/question_4/code/correct/correct_4_213.py
refactory_data_question_4_correct_4_145
#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] for i in a: if i[1]>largest[1]: largest=i a.remove(largest) #1.indentation! sort.append(largest) return sort #1.it's same indentation as for loop, #that is, we only start removing when we find the largest
./refactory/data/question_4/code/correct/correct_4_145.py
refactory_data_question_4_correct_4_008
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
./refactory/data/question_4/code/correct/correct_4_008.py
refactory_data_question_4_correct_4_212
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
./refactory/data/question_4/code/correct/correct_4_212.py
refactory_data_question_4_correct_4_328
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
./refactory/data/question_4/code/correct/correct_4_328.py
refactory_data_question_4_correct_4_239
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
./refactory/data/question_4/code/correct/correct_4_239.py