Every line of 'how to sort a list in python without sort function' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
40 def testLtSort(self): 41 self.run_test(lt_sort, self.source)
909 """ Contains(self: Queue[T], item: T) -> bool """ 910 pass
70 def sorted(lst, cmp=None, key=None, reverse=None): 71 "sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list" 72 sorted_lst = list(lst) 73 sorted_lst.sort(cmp, key, reverse) 74 return sorted_lst
22 def Quick_Sort(list): 23 Quick(list, 0, len(list) - 1)
27 def quick_sort(myList, start, end): 28 if start < end: 29 # partitioning the list 30 split = partition(myList, start, end) 31 # split halves & sort both halves 32 quick_sort(myList, start, split - 1) 33 quick_sort(myList, split + 1, end) 34 return myList
5 def qsort(lst): 6 """ Quick sort: returns a sorted copy of the list. 7 """ 8 # Implement the quick sort logic here 9 return lst
4 def sort(func): 5 6 def func_wrapper(): 7 return sorted(func()) 8 return func_wrapper
5 def bubblesort(list): 6 swapped = True 7 while swapped: 8 print 9 print "New iteration..." 10 swapped = False 11 for i in range(len(list)-1): 12 if(list[i] > list[i+1]): 13 print "Index: " + str(i) + " - Swap " + str(list[i]) + " with " + str(list[i+1]) 14 tmp = list [i] 15 list[i] = list[i+1] 16 list[i+1] = tmp 17 swapped = True 18 print list 19 print "Nothing left to swap. Done" 20 return list
10 def built_in_sort(stack): 11 stack.sort() 12 return stack
6 def safesort(l): 7 sl = [] 8 ul = [] 9 for s in l: 10 if isinstance(s, str): 11 sl.append(s) 12 else: 13 ul.append(s) 14 sl.sort() 15 ul.sort() 16 l[:] = ul + sl