id
stringlengths
35
39
content
stringlengths
44
3.85k
max_stars_repo_path
stringlengths
52
57
refactory_data_question_3_wrong_3_063
def remove_extras(lst): o = [] for i in lst: if i not in o: lst.remove(i) o.append(i) return o
./refactory/data/question_3/code/wrong/wrong_3_063.py
refactory_data_question_3_wrong_3_219
def remove_extras(lst): for i in lst: if lst.count(i) > 1: lst.pop(i) return lst
./refactory/data/question_3/code/wrong/wrong_3_219.py
refactory_data_question_3_wrong_3_149
def remove_extras(lst): result = [] for i in lst: if i not in result: result.append[i] return result pass
./refactory/data/question_3/code/wrong/wrong_3_149.py
refactory_data_question_3_wrong_3_218
def remove_extras(lst): i=0 new = [] while i<=len(lst): curr = lst[i] for ele in lst: if ele == curr: continue new += [ele,] lst = new.copy() new = [] i +=1 return lst
./refactory/data/question_3/code/wrong/wrong_3_218.py
refactory_data_question_3_wrong_3_304
def remove_extras(lst): a = [] for i in lst: if i in a: continue else: a.extend(i) return a
./refactory/data/question_3/code/wrong/wrong_3_304.py
refactory_data_question_3_wrong_3_169
def remove_extras(lst): a = [] for repeat in range(len(lst) + 1): if repeat not in a: a += repeat return a
./refactory/data/question_3/code/wrong/wrong_3_169.py
refactory_data_question_3_wrong_3_110
def remove_extras(lst): for i in lst: if lst.count(i)>1: lst=lst.reverse() lst=lst.remove(i) lst=lst.reverse return lst
./refactory/data/question_3/code/wrong/wrong_3_110.py
refactory_data_question_3_wrong_3_285
def remove_extras(lst): lst2 = [] for x in lst: if lst.count(x) < 1: lst2.append(x) return lst2
./refactory/data/question_3/code/wrong/wrong_3_285.py
refactory_data_question_3_wrong_3_053
def remove_extras(lst): for num in lst: while lst.count(num)>1: lst.remove(num) return lst
./refactory/data/question_3/code/wrong/wrong_3_053.py
refactory_data_question_3_wrong_3_216
def remove_extras(lst): i=0 new = [] while i<len(lst): curr = lst[i] for ele in lst: if ele == curr: continue new += [ele,] lst = new.copy new = [] i +=1 return lst
./refactory/data/question_3/code/wrong/wrong_3_216.py
refactory_data_question_3_wrong_3_199
def remove_extras(lst): new_lst=[lst[0]] if lst==[]: return [] for i in range(len(lst)): a=lst[i] for h in range(i,len(lst)): if a!=lst[h]: ele=lst[h] if ele in new_lst: continue new_lst.append[ele] return new_list
./refactory/data/question_3/code/wrong/wrong_3_199.py
refactory_data_question_3_wrong_3_003
def remove_extras(lst): # your code here occurrences = () new_lst = [] for item in lst: if item not in occurrences: occurrences += (item,) new_list.append(item) return new_lst
./refactory/data/question_3/code/wrong/wrong_3_003.py
refactory_data_question_3_wrong_3_148
def remove_extras(lst): lst2=[] for i in lst: if i not in lst2: lst2+=i return lst2
./refactory/data/question_3/code/wrong/wrong_3_148.py
refactory_data_question_3_wrong_3_207
def remove_extras(lst): lst.sort() i = 1 n = len(lst) while i < n: if lst[i]==lst[i-1]: lst.remove(i) else: i += 1 n = len(lst) return lst pass
./refactory/data/question_3/code/wrong/wrong_3_207.py
refactory_data_question_3_wrong_3_067
def remove_extras(lst): return list(set(lst))
./refactory/data/question_3/code/wrong/wrong_3_067.py
refactory_data_question_3_wrong_3_001
def remove_extras(lst): output = [] for i in lst: if i in output: output.append(i) return output
./refactory/data/question_3/code/wrong/wrong_3_001.py
refactory_data_question_3_wrong_3_270
def remove_extras(lst): newlist = [] for i in list: if i not in list: newlist += i, return newlist
./refactory/data/question_3/code/wrong/wrong_3_270.py
refactory_data_question_3_wrong_3_221
def remove_extras(lst): for i in range(len(lst)-1): if lst.count(lst[i]) > 1: lst.pop(i) return lst
./refactory/data/question_3/code/wrong/wrong_3_221.py
refactory_data_question_3_wrong_3_022
def remove_extras(lst): new_lst = [] for element in lst: if element not in new_lst: new_lst.append(element) return new_list
./refactory/data/question_3/code/wrong/wrong_3_022.py
refactory_data_question_3_wrong_3_233
def remove_extras(lst): new_lst = [] for i in lst: if lst.count(i) == 1: lst.append(i) return new_lst
./refactory/data/question_3/code/wrong/wrong_3_233.py
refactory_data_question_3_wrong_3_119
def remove_extras(lst): new_lst = [] for ele in lst: if ele not in new_lst: new_lst += ele return new_lst
./refactory/data/question_3/code/wrong/wrong_3_119.py
refactory_data_question_3_wrong_3_188
def remove_extras(lst): new_list = [] for elem in lst: if elem not in new: new_list += new.append(elem) return new_list
./refactory/data/question_3/code/wrong/wrong_3_188.py
refactory_data_question_3_wrong_3_274
def remove_extras(lst): result = lst[0] for e in lst: if e not in result: result.add(e) else: continue return result
./refactory/data/question_3/code/wrong/wrong_3_274.py
refactory_data_question_3_wrong_3_125
def remove_extras(lst): seq = (lst[0],) for i in lst: if i not in seq: seq = seq + (i,) return seq
./refactory/data/question_3/code/wrong/wrong_3_125.py
refactory_data_question_3_wrong_3_045
def remove_extras(lst): return list(set(lst))
./refactory/data/question_3/code/wrong/wrong_3_045.py
refactory_data_question_4_correct_4_019
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_019.py
refactory_data_question_4_correct_4_111
def sort_age(lst): newlst=[] while lst: minimum1=lst[0] minimum=lst[0][1] for x in lst: if x[1]>minimum: minimum=x[1] minimum1=x newlst.append(minimum1) lst.remove(minimum1) return newlst
./refactory/data/question_4/code/correct/correct_4_111.py
refactory_data_question_4_correct_4_099
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
./refactory/data/question_4/code/correct/correct_4_099.py
refactory_data_question_4_correct_4_233
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
./refactory/data/question_4/code/correct/correct_4_233.py
refactory_data_question_4_correct_4_169
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
./refactory/data/question_4/code/correct/correct_4_169.py
refactory_data_question_4_correct_4_149
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_149.py
refactory_data_question_4_correct_4_126
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
./refactory/data/question_4/code/correct/correct_4_126.py
refactory_data_question_4_correct_4_352
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
./refactory/data/question_4/code/correct/correct_4_352.py
refactory_data_question_4_correct_4_286
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
./refactory/data/question_4/code/correct/correct_4_286.py
refactory_data_question_4_correct_4_227
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
./refactory/data/question_4/code/correct/correct_4_227.py
refactory_data_question_4_correct_4_394
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_394.py
refactory_data_question_4_correct_4_054
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
./refactory/data/question_4/code/correct/correct_4_054.py
refactory_data_question_4_correct_4_076
def sort_age(lst): new =[] while lst: index = 0 oldest = lst[0][1] for i in range(1, len(lst)): if lst[i][1] >oldest: oldest = lst[i][1] index = i new.append(lst[index]) del lst[index] return new
./refactory/data/question_4/code/correct/correct_4_076.py
refactory_data_question_4_correct_4_186
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
./refactory/data/question_4/code/correct/correct_4_186.py
refactory_data_question_4_correct_4_260
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
./refactory/data/question_4/code/correct/correct_4_260.py
refactory_data_question_4_correct_4_379
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
./refactory/data/question_4/code/correct/correct_4_379.py
refactory_data_question_4_correct_4_235
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
./refactory/data/question_4/code/correct/correct_4_235.py
refactory_data_question_4_correct_4_345
#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
./refactory/data/question_4/code/correct/correct_4_345.py
refactory_data_question_4_correct_4_418
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
./refactory/data/question_4/code/correct/correct_4_418.py
refactory_data_question_4_correct_4_193
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
./refactory/data/question_4/code/correct/correct_4_193.py
refactory_data_question_4_correct_4_217
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
./refactory/data/question_4/code/correct/correct_4_217.py
refactory_data_question_4_correct_4_303
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
./refactory/data/question_4/code/correct/correct_4_303.py
refactory_data_question_4_correct_4_392
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]
./refactory/data/question_4/code/correct/correct_4_392.py
refactory_data_question_4_correct_4_342
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
./refactory/data/question_4/code/correct/correct_4_342.py
refactory_data_question_4_correct_4_230
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
./refactory/data/question_4/code/correct/correct_4_230.py
refactory_data_question_4_correct_4_290
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
./refactory/data/question_4/code/correct/correct_4_290.py
refactory_data_question_4_correct_4_179
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_179.py
refactory_data_question_4_correct_4_253
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
./refactory/data/question_4/code/correct/correct_4_253.py
refactory_data_question_4_correct_4_118
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_118.py
refactory_data_question_4_correct_4_206
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
./refactory/data/question_4/code/correct/correct_4_206.py
refactory_data_question_4_correct_4_100
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
./refactory/data/question_4/code/correct/correct_4_100.py
refactory_data_question_4_correct_4_060
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
./refactory/data/question_4/code/correct/correct_4_060.py
refactory_data_question_4_correct_4_333
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
./refactory/data/question_4/code/correct/correct_4_333.py
refactory_data_question_4_correct_4_306
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
./refactory/data/question_4/code/correct/correct_4_306.py
refactory_data_question_4_correct_4_334
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)
./refactory/data/question_4/code/correct/correct_4_334.py
refactory_data_question_4_correct_4_288
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 ''' read wrong question def sort_age(lst): male = [] female = [] for i in range(len(lst)): if lst[i][0] == "M": male.append(lst[i]) else: female.append(lst[i]) male.sort() female.sort() combine = male[::-1] + female[::-1] return combine '''
./refactory/data/question_4/code/correct/correct_4_288.py
refactory_data_question_4_correct_4_184
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_184.py
refactory_data_question_4_correct_4_317
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)
./refactory/data/question_4/code/correct/correct_4_317.py
refactory_data_question_4_correct_4_259
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)
./refactory/data/question_4/code/correct/correct_4_259.py
refactory_data_question_4_correct_4_387
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_387.py
refactory_data_question_4_correct_4_272
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
./refactory/data/question_4/code/correct/correct_4_272.py
refactory_data_question_4_correct_4_232
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)
./refactory/data/question_4/code/correct/correct_4_232.py
refactory_data_question_4_correct_4_132
def sort_age(lst): rslt=[] while lst: smallest=lst[0] for element in lst: if element[1]>smallest[1]: smallest=element lst.remove(smallest) rslt.append(smallest) return rslt
./refactory/data/question_4/code/correct/correct_4_132.py
refactory_data_question_4_correct_4_017
def sort_age(lst): if lst==[]: return [] 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 pass
./refactory/data/question_4/code/correct/correct_4_017.py
refactory_data_question_4_correct_4_119
def sort_age(lst): if len(lst) < 2: return lst new_lst = [] while lst: max_age = lst[0][1] first = lst[0] for j in range(1, len(lst)): if lst[j][1] > max_age: max_age = lst[j][1] first = lst[j] new_lst.append(first) lst.remove(first) return new_lst
./refactory/data/question_4/code/correct/correct_4_119.py
refactory_data_question_4_correct_4_045
def sort_age(lst): sort = [] while lst: biggest = lst[0][1] element=lst[0] for ele in lst: if ele[1] > biggest: biggest = ele[1] element=ele lst.remove(element) sort.append(element) return sort
./refactory/data/question_4/code/correct/correct_4_045.py
refactory_data_question_4_correct_4_123
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_123.py
refactory_data_question_4_correct_4_030
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
./refactory/data/question_4/code/correct/correct_4_030.py
refactory_data_question_4_correct_4_074
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
./refactory/data/question_4/code/correct/correct_4_074.py
refactory_data_question_4_correct_4_271
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_271.py
refactory_data_question_4_correct_4_395
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
./refactory/data/question_4/code/correct/correct_4_395.py
refactory_data_question_4_correct_4_280
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
./refactory/data/question_4/code/correct/correct_4_280.py
refactory_data_question_4_correct_4_177
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_177.py
refactory_data_question_4_correct_4_199
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
./refactory/data/question_4/code/correct/correct_4_199.py
refactory_data_question_4_correct_4_399
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
./refactory/data/question_4/code/correct/correct_4_399.py
refactory_data_question_4_correct_4_098
def sort_age(lst): order = [] while lst: oldest = lst[0] for person in lst: if person[1] > oldest[1]: oldest = person lst.remove(oldest) order.append(oldest) return order
./refactory/data/question_4/code/correct/correct_4_098.py
refactory_data_question_4_correct_4_175
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
./refactory/data/question_4/code/correct/correct_4_175.py
refactory_data_question_4_correct_4_346
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
./refactory/data/question_4/code/correct/correct_4_346.py
refactory_data_question_4_correct_4_372
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
./refactory/data/question_4/code/correct/correct_4_372.py
refactory_data_question_4_correct_4_139
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
./refactory/data/question_4/code/correct/correct_4_139.py
refactory_data_question_4_correct_4_053
def sort_age(lst): holder=[] if lst==[]: return [] for x in lst: if holder==[]: holder=x elif x[1]>holder[1]: holder=x lst.remove(holder) return [holder]+sort_age(lst)
./refactory/data/question_4/code/correct/correct_4_053.py
refactory_data_question_4_correct_4_211
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_211.py
refactory_data_question_4_correct_4_315
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
./refactory/data/question_4/code/correct/correct_4_315.py
refactory_data_question_4_correct_4_048
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_048.py
refactory_data_question_4_correct_4_252
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)
./refactory/data/question_4/code/correct/correct_4_252.py
refactory_data_question_4_correct_4_412
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_412.py
refactory_data_question_4_correct_4_102
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_102.py
refactory_data_question_4_correct_4_374
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_374.py
refactory_data_question_4_correct_4_275
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
./refactory/data/question_4/code/correct/correct_4_275.py
refactory_data_question_4_correct_4_256
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
./refactory/data/question_4/code/correct/correct_4_256.py
refactory_data_question_4_correct_4_115
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_115.py
refactory_data_question_4_correct_4_140
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_140.py
refactory_data_question_4_correct_4_040
def sort_age(lst): for i in range(0,len(lst)): this=lst[i] j=0 while j<i: if this[1]>lst[j][1]: break j+=1 del lst[i] lst.insert(j,this) return lst
./refactory/data/question_4/code/correct/correct_4_040.py
refactory_data_question_4_correct_4_070
def sort_age(lst): def cmp(a,b): if a[1] >= b[1]: return True else: return False while True: sorted = True for i in range(len(lst)-1): if not cmp(lst[i],lst[i+1]): lst[i],lst[i+1]=lst[i+1],lst[i] sorted = False if sorted==True: break return lst
./refactory/data/question_4/code/correct/correct_4_070.py
refactory_data_question_4_correct_4_075
def sort_age(lst): sort=[] while lst: oldest=lst[0] for element in lst: if element[1]>oldest[1]: oldest=element lst.remove(oldest) sort.append(oldest) return sort
./refactory/data/question_4/code/correct/correct_4_075.py