id
stringlengths
35
39
content
stringlengths
44
3.85k
max_stars_repo_path
stringlengths
52
57
refactory_data_question_4_correct_4_209
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_209.py
refactory_data_question_4_correct_4_001
def sort_age(lst): output = [] for i in range(len(lst)): largest = max(lst, key=lambda p: p[1]) lst.remove(largest) output.append(largest) return output
./refactory/data/question_4/code/correct/correct_4_001.py
refactory_data_question_4_correct_4_142
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
./refactory/data/question_4/code/correct/correct_4_142.py
refactory_data_question_4_correct_4_214
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
./refactory/data/question_4/code/correct/correct_4_214.py
refactory_data_question_4_correct_4_059
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_059.py
refactory_data_question_4_correct_4_339
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
./refactory/data/question_4/code/correct/correct_4_339.py
refactory_data_question_4_correct_4_231
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_231.py
refactory_data_question_4_correct_4_389
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_389.py
refactory_data_question_4_correct_4_300
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
./refactory/data/question_4/code/correct/correct_4_300.py
refactory_data_question_4_correct_4_150
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_150.py
refactory_data_question_4_correct_4_191
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]
./refactory/data/question_4/code/correct/correct_4_191.py
refactory_data_question_4_correct_4_327
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
./refactory/data/question_4/code/correct/correct_4_327.py
refactory_data_question_4_correct_4_134
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_134.py
refactory_data_question_4_correct_4_234
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_234.py
refactory_data_question_4_correct_4_357
#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
./refactory/data/question_4/code/correct/correct_4_357.py
refactory_data_question_4_correct_4_157
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]
./refactory/data/question_4/code/correct/correct_4_157.py
refactory_data_question_4_correct_4_016
def sort_age(lst): if len(lst) == 0: return [] elif len(lst) == 1: return lst elif len(lst) == 2: if lst[0][1] >= lst[1][1]: return lst else: return [lst[1], lst[0]] else: if lst[0][1] >= lst[1][1]: list1, list2 = [lst[0]], [lst[1]] else: list1, list2 = [lst[1]], [lst[0]] for i in lst[2:]: if i[1] >= list1[0][1]: list1.append(i) else: list2.append(i) return sort_age(list1) + sort_age(list2)
./refactory/data/question_4/code/correct/correct_4_016.py
refactory_data_question_4_correct_4_092
def sort_age(lst): # Fill in your code here new_lst = [('A',10000),('B',0)] for element in lst: age = element[1] for i in range(len(new_lst)): if age > new_lst[i][1]: new_lst.insert(i, element) break new_lst.remove(('A',10000)) new_lst.remove(('B',0)) return new_lst
./refactory/data/question_4/code/correct/correct_4_092.py
refactory_data_question_4_correct_4_071
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
./refactory/data/question_4/code/correct/correct_4_071.py
refactory_data_question_4_correct_4_262
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
./refactory/data/question_4/code/correct/correct_4_262.py
refactory_data_question_4_correct_4_160
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) return sort
./refactory/data/question_4/code/correct/correct_4_160.py
refactory_data_question_4_correct_4_350
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_350.py
refactory_data_question_4_correct_4_402
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_402.py
refactory_data_question_4_correct_4_354
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_354.py
refactory_data_question_4_correct_4_014
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_014.py
refactory_data_question_4_correct_4_207
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)
./refactory/data/question_4/code/correct/correct_4_207.py
refactory_data_question_4_correct_4_049
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_049.py
refactory_data_question_4_correct_4_351
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
./refactory/data/question_4/code/correct/correct_4_351.py
refactory_data_question_4_correct_4_244
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_244.py
refactory_data_question_4_correct_4_356
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
./refactory/data/question_4/code/correct/correct_4_356.py
refactory_data_question_4_correct_4_225
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_225.py
refactory_data_question_4_correct_4_224
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_224.py
refactory_data_question_4_correct_4_215
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
./refactory/data/question_4/code/correct/correct_4_215.py
refactory_data_question_4_correct_4_088
def sort_age(lst): new_list = [] while lst: smallest = lst[0] for element in lst: if smallest[1]<element[1]: smallest = element lst.remove(smallest) new_list.append(smallest) return new_list
./refactory/data/question_4/code/correct/correct_4_088.py
refactory_data_question_4_correct_4_277
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
./refactory/data/question_4/code/correct/correct_4_277.py
refactory_data_question_4_correct_4_368
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_368.py
refactory_data_question_4_correct_4_347
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_347.py
refactory_data_question_4_correct_4_362
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
./refactory/data/question_4/code/correct/correct_4_362.py
refactory_data_question_4_correct_4_319
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_319.py
refactory_data_question_4_correct_4_264
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
./refactory/data/question_4/code/correct/correct_4_264.py
refactory_data_question_4_correct_4_050
def sort_age(lst): for loop in range(len(lst)): 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
./refactory/data/question_4/code/correct/correct_4_050.py
refactory_data_question_4_correct_4_062
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_062.py
refactory_data_question_4_correct_4_037
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_037.py
refactory_data_question_4_correct_4_307
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
./refactory/data/question_4/code/correct/correct_4_307.py
refactory_data_question_4_correct_4_360
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]
./refactory/data/question_4/code/correct/correct_4_360.py
refactory_data_question_4_correct_4_289
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
./refactory/data/question_4/code/correct/correct_4_289.py
refactory_data_question_4_correct_4_254
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
./refactory/data/question_4/code/correct/correct_4_254.py
refactory_data_question_4_correct_4_136
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_136.py
refactory_data_question_4_correct_4_241
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
./refactory/data/question_4/code/correct/correct_4_241.py
refactory_data_question_4_correct_4_195
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
./refactory/data/question_4/code/correct/correct_4_195.py
refactory_data_question_4_correct_4_316
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_316.py
refactory_data_question_4_correct_4_311
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
./refactory/data/question_4/code/correct/correct_4_311.py
refactory_data_question_4_correct_4_192
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_192.py
refactory_data_question_4_correct_4_173
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_173.py
refactory_data_question_4_correct_4_250
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
./refactory/data/question_4/code/correct/correct_4_250.py
refactory_data_question_4_correct_4_051
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) lst.reverse() return lst
./refactory/data/question_4/code/correct/correct_4_051.py
refactory_data_question_4_correct_4_223
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
./refactory/data/question_4/code/correct/correct_4_223.py
refactory_data_question_4_correct_4_131
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_131.py
refactory_data_question_4_correct_4_249
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_249.py
refactory_data_question_4_correct_4_013
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_013.py
refactory_data_question_4_correct_4_407
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_407.py
refactory_data_question_4_correct_4_263
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_263.py
refactory_data_question_4_correct_4_101
def sort_age(lst): # Fill in your code here i = 1 while i < len(lst): j = i while j>0 and lst[j-1][1] > lst[j][1]: lst[j], lst[j-1] = lst[j-1], lst[j] j-=1 i+=1 return lst[::-1]
./refactory/data/question_4/code/correct/correct_4_101.py
refactory_data_question_4_correct_4_081
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_081.py
refactory_data_question_4_correct_4_146
def sort_age(lst): for i in range(len(lst)): position = i biggest = position for a in range(position, len(lst)): if lst[a][1] > lst[biggest][1]: biggest = a tmp = lst[position] lst[position] = lst[biggest] lst[biggest] = tmp return lst
./refactory/data/question_4/code/correct/correct_4_146.py
refactory_data_question_4_correct_4_383
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_383.py
refactory_data_question_4_correct_4_386
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))
./refactory/data/question_4/code/correct/correct_4_386.py
refactory_data_question_4_correct_4_332
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
./refactory/data/question_4/code/correct/correct_4_332.py
refactory_data_question_4_correct_4_114
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) return sort
./refactory/data/question_4/code/correct/correct_4_114.py
refactory_data_question_4_correct_4_261
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
./refactory/data/question_4/code/correct/correct_4_261.py
refactory_data_question_4_correct_4_220
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_220.py
refactory_data_question_4_correct_4_318
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_318.py
refactory_data_question_4_correct_4_236
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
./refactory/data/question_4/code/correct/correct_4_236.py
refactory_data_question_4_correct_4_067
def sort_age(lst): if len(lst) == 1: return lst elif lst == []: return [] else: s = 0 for i in lst: if i[1] > s: s = i[1] t = i lst.remove(t) return [t] + sort_age(lst)
./refactory/data/question_4/code/correct/correct_4_067.py
refactory_data_question_4_correct_4_144
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_144.py
refactory_data_question_4_correct_4_283
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_283.py
refactory_data_question_4_correct_4_106
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) return final
./refactory/data/question_4/code/correct/correct_4_106.py
refactory_data_question_4_correct_4_127
def sort_age(lst): new_lst = [] age = [] for i in lst: age = age + [i[1],] while len(lst) != 0: for j in lst: if j[1] == max(age): lst.remove(j) age.remove(max(age)) new_lst = new_lst + [j,] return new_lst
./refactory/data/question_4/code/correct/correct_4_127.py
refactory_data_question_4_correct_4_113
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
./refactory/data/question_4/code/correct/correct_4_113.py
refactory_data_question_4_correct_4_194
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
./refactory/data/question_4/code/correct/correct_4_194.py
refactory_data_question_4_correct_4_043
def sort_age(lst): for i in range(len(lst)): position = i biggest = position for a in range(position, len(lst)): if lst[a][1] > lst[biggest][1]: biggest = a tmp = lst[position] lst[position] = lst[biggest] lst[biggest] = tmp return lst
./refactory/data/question_4/code/correct/correct_4_043.py
refactory_data_question_4_correct_4_023
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
./refactory/data/question_4/code/correct/correct_4_023.py
refactory_data_question_4_correct_4_384
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_384.py
refactory_data_question_4_correct_4_178
def sort_age(lst): # Fill in your code here 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_178.py
refactory_data_question_4_correct_4_196
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_196.py
refactory_data_question_4_correct_4_298
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
./refactory/data/question_4/code/correct/correct_4_298.py
refactory_data_question_4_correct_4_064
def sort_age(lst): if lst == []: return [] else: 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
./refactory/data/question_4/code/correct/correct_4_064.py
refactory_data_question_4_correct_4_003
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
./refactory/data/question_4/code/correct/correct_4_003.py
refactory_data_question_4_correct_4_336
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
./refactory/data/question_4/code/correct/correct_4_336.py
refactory_data_question_4_correct_4_410
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
./refactory/data/question_4/code/correct/correct_4_410.py
refactory_data_question_4_correct_4_359
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
./refactory/data/question_4/code/correct/correct_4_359.py
refactory_data_question_4_correct_4_041
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_041.py
refactory_data_question_4_correct_4_273
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_273.py
refactory_data_question_4_correct_4_293
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
./refactory/data/question_4/code/correct/correct_4_293.py
refactory_data_question_4_correct_4_308
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_308.py
refactory_data_question_4_correct_4_021
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_021.py
refactory_data_question_4_correct_4_006
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 = [lst[index]] + result lst.pop(index) return result
./refactory/data/question_4/code/correct/correct_4_006.py
refactory_data_question_4_correct_4_398
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_398.py
refactory_data_question_4_correct_4_130
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_130.py
refactory_data_question_4_correct_4_294
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
./refactory/data/question_4/code/correct/correct_4_294.py