id
stringlengths 35
39
| content
stringlengths 44
3.85k
| max_stars_repo_path
stringlengths 52
57
|
|---|---|---|
refactory_data_question_4_correct_4_182
|
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_182.py
|
refactory_data_question_4_correct_4_416
|
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
|
./refactory/data/question_4/code/correct/correct_4_416.py
|
refactory_data_question_4_correct_4_153
|
def sort_age(lst):
sort1 = []
while lst:
largest = lst[0]
for i in lst:
if i[1] > largest[1]:
largest = i
lst.remove(largest)
sort1.append(largest)
return sort1
|
./refactory/data/question_4/code/correct/correct_4_153.py
|
refactory_data_question_4_correct_4_103
|
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_103.py
|
refactory_data_question_4_correct_4_080
|
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_080.py
|
refactory_data_question_4_correct_4_414
|
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_414.py
|
refactory_data_question_4_correct_4_147
|
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_147.py
|
refactory_data_question_4_correct_4_364
|
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_364.py
|
refactory_data_question_4_correct_4_312
|
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_312.py
|
refactory_data_question_4_correct_4_002
|
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_002.py
|
refactory_data_question_4_correct_4_007
|
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_007.py
|
refactory_data_question_4_correct_4_094
|
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_094.py
|
refactory_data_question_4_correct_4_322
|
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
|
./refactory/data/question_4/code/correct/correct_4_322.py
|
refactory_data_question_4_correct_4_229
|
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_229.py
|
refactory_data_question_4_correct_4_104
|
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_104.py
|
refactory_data_question_4_correct_4_385
|
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)
|
./refactory/data/question_4/code/correct/correct_4_385.py
|
refactory_data_question_4_correct_4_162
|
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_162.py
|
refactory_data_question_4_correct_4_331
|
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_331.py
|
refactory_data_question_4_correct_4_376
|
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_376.py
|
refactory_data_question_4_correct_4_247
|
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
|
./refactory/data/question_4/code/correct/correct_4_247.py
|
refactory_data_question_4_correct_4_324
|
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_324.py
|
refactory_data_question_4_correct_4_405
|
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
|
./refactory/data/question_4/code/correct/correct_4_405.py
|
refactory_data_question_4_correct_4_321
|
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_321.py
|
refactory_data_question_4_correct_4_124
|
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_124.py
|
refactory_data_question_4_correct_4_181
|
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_181.py
|
refactory_data_question_4_correct_4_366
|
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
|
./refactory/data/question_4/code/correct/correct_4_366.py
|
refactory_data_question_4_correct_4_228
|
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
|
./refactory/data/question_4/code/correct/correct_4_228.py
|
refactory_data_question_4_correct_4_156
|
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_156.py
|
refactory_data_question_4_correct_4_266
|
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_266.py
|
refactory_data_question_4_correct_4_183
|
# person = ("M",30)
#people list = [("M",30),("F",23)]
def sort_age(lst):
if len(lst) <= 1:
return lst
else:
newlist = []
biggest = lst[0]
for i in lst[1:]:
if biggest[1] > i[1]:
continue
else:
biggest = i
continue
newlist += [biggest]
lst.remove(biggest)
return newlist + sort_age(lst)
|
./refactory/data/question_4/code/correct/correct_4_183.py
|
refactory_data_question_4_correct_4_208
|
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
|
./refactory/data/question_4/code/correct/correct_4_208.py
|
refactory_data_question_4_correct_4_382
|
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
|
./refactory/data/question_4/code/correct/correct_4_382.py
|
refactory_data_question_4_correct_4_143
|
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
# lst.sort(key= lambda x:x[1], reverse=True)
# return lst
|
./refactory/data/question_4/code/correct/correct_4_143.py
|
refactory_data_question_4_correct_4_109
|
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_109.py
|
refactory_data_question_4_correct_4_137
|
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_137.py
|
refactory_data_question_4_correct_4_189
|
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
|
./refactory/data/question_4/code/correct/correct_4_189.py
|
refactory_data_question_4_correct_4_361
|
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
|
./refactory/data/question_4/code/correct/correct_4_361.py
|
refactory_data_question_4_correct_4_353
|
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_353.py
|
refactory_data_question_4_correct_4_005
|
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_005.py
|
refactory_data_question_4_correct_4_188
|
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_188.py
|
refactory_data_question_4_correct_4_329
|
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_329.py
|
refactory_data_question_4_correct_4_309
|
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
|
./refactory/data/question_4/code/correct/correct_4_309.py
|
refactory_data_question_4_correct_4_325
|
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_325.py
|
refactory_data_question_4_correct_4_397
|
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_397.py
|
refactory_data_question_4_correct_4_310
|
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_310.py
|
refactory_data_question_4_correct_4_065
|
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_065.py
|
refactory_data_question_4_correct_4_035
|
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_035.py
|
refactory_data_question_4_correct_4_348
|
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_348.py
|
refactory_data_question_4_correct_4_301
|
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
|
./refactory/data/question_4/code/correct/correct_4_301.py
|
refactory_data_question_4_correct_4_096
|
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_096.py
|
refactory_data_question_4_correct_4_242
|
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
|
./refactory/data/question_4/code/correct/correct_4_242.py
|
refactory_data_question_4_correct_4_219
|
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_219.py
|
refactory_data_question_4_correct_4_086
|
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_086.py
|
refactory_data_question_4_correct_4_267
|
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
|
./refactory/data/question_4/code/correct/correct_4_267.py
|
refactory_data_question_4_correct_4_415
|
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)
|
./refactory/data/question_4/code/correct/correct_4_415.py
|
refactory_data_question_4_correct_4_269
|
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
|
./refactory/data/question_4/code/correct/correct_4_269.py
|
refactory_data_question_4_correct_4_240
|
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
|
./refactory/data/question_4/code/correct/correct_4_240.py
|
refactory_data_question_4_correct_4_305
|
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_305.py
|
refactory_data_question_4_correct_4_085
|
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_085.py
|
refactory_data_question_4_correct_4_038
|
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_038.py
|
refactory_data_question_4_correct_4_281
|
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_281.py
|
refactory_data_question_4_correct_4_166
|
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_166.py
|
refactory_data_question_4_correct_4_068
|
def sort_age(lst):
"""selection sort: O(n^2) time"""
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[i] #swap positions if larger
#print(i,lst)
return lst
|
./refactory/data/question_4/code/correct/correct_4_068.py
|
refactory_data_question_4_correct_4_167
|
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
|
./refactory/data/question_4/code/correct/correct_4_167.py
|
refactory_data_question_4_correct_4_112
|
def sort_age(lst):
new = []
while lst:
small = lst[0]
for a in lst:
if a > small and a[1] > small[1]:
small = a
new.append(small)
lst.remove(small)
return new
|
./refactory/data/question_4/code/correct/correct_4_112.py
|
refactory_data_question_4_correct_4_128
|
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_128.py
|
refactory_data_question_4_correct_4_355
|
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_355.py
|
refactory_data_question_4_correct_4_141
|
def sort_age(lst):
new_lst = []
while lst:
oldest = lst[0][1]
for people in lst:
if people[1] >= oldest:
oldest = people[1]
remove_people = people
new_lst.append(remove_people)
lst.remove(remove_people)
return new_lst
|
./refactory/data/question_4/code/correct/correct_4_141.py
|
refactory_data_question_4_correct_4_251
|
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
|
./refactory/data/question_4/code/correct/correct_4_251.py
|
refactory_data_question_4_correct_4_274
|
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_274.py
|
refactory_data_question_4_correct_4_161
|
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_161.py
|
refactory_data_question_4_correct_4_072
|
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_072.py
|
refactory_data_question_4_correct_4_248
|
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_248.py
|
refactory_data_question_4_correct_4_270
|
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
|
./refactory/data/question_4/code/correct/correct_4_270.py
|
refactory_data_question_4_correct_4_411
|
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_411.py
|
refactory_data_question_4_correct_4_314
|
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_314.py
|
refactory_data_question_4_correct_4_409
|
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
|
./refactory/data/question_4/code/correct/correct_4_409.py
|
refactory_data_question_4_correct_4_135
|
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_135.py
|
refactory_data_question_4_correct_4_009
|
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_009.py
|
refactory_data_question_4_correct_4_276
|
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_276.py
|
refactory_data_question_4_correct_4_201
|
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_201.py
|
refactory_data_question_4_correct_4_304
|
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
|
./refactory/data/question_4/code/correct/correct_4_304.py
|
refactory_data_question_4_correct_4_117
|
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_117.py
|
refactory_data_question_4_correct_4_024
|
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_024.py
|
refactory_data_question_4_correct_4_148
|
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_148.py
|
refactory_data_question_4_correct_4_168
|
def sort_age(lst):
if len(lst)== 0:
return []
def rank(lyst):
if len(lyst)==1:
return list(lyst)
else:
a = max(lyst)
lyst.remove(a)
return [a]+ rank(lyst)
a = []
b = []
n = len(lst)
for psn in lst:
age = psn[1]
a += [age]
print(a)
c = rank(a)
for age in c:
for psn in lst:
if age == psn[1]:
b += [psn]
else:
continue
return b
|
./refactory/data/question_4/code/correct/correct_4_168.py
|
refactory_data_question_4_correct_4_363
|
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_363.py
|
refactory_data_question_4_correct_4_205
|
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_205.py
|
refactory_data_question_4_correct_4_238
|
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
|
./refactory/data/question_4/code/correct/correct_4_238.py
|
refactory_data_question_4_correct_4_378
|
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_378.py
|
refactory_data_question_4_correct_4_105
|
def sort_age(lst):
ages = list(i[1] for i in lst)
for i in range(len(lst)):
index_youngest = ages.index(max(ages))
lst[i], lst[index_youngest] = lst[index_youngest], lst[i]
ages[index_youngest] = min(ages) - 1
ages[i], ages[index_youngest] = ages[index_youngest], ages[i]
return lst
|
./refactory/data/question_4/code/correct/correct_4_105.py
|
refactory_data_question_4_correct_4_010
|
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_010.py
|
refactory_data_question_4_correct_4_163
|
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_163.py
|
refactory_data_question_4_correct_4_391
|
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_391.py
|
refactory_data_question_4_correct_4_265
|
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
|
./refactory/data/question_4/code/correct/correct_4_265.py
|
refactory_data_question_4_correct_4_025
|
def sort_age(lst):
for i in range(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_025.py
|
refactory_data_question_4_correct_4_335
|
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
|
./refactory/data/question_4/code/correct/correct_4_335.py
|
refactory_data_question_4_correct_4_287
|
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
|
./refactory/data/question_4/code/correct/correct_4_287.py
|
refactory_data_question_4_correct_4_296
|
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
|
./refactory/data/question_4/code/correct/correct_4_296.py
|
refactory_data_question_4_correct_4_093
|
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_093.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.