10 examples of 'python sort 2d list' in Python

Every line of 'python sort 2d list' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
70def 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
22def Quick_Sort(list):
23 Quick(list, 0, len(list) - 1)
909""" Contains(self: Queue[T], item: T) -> bool """
910pass
13def selectionSort2(list):
14 for index in range(0,len(list)-1):
15 indexMin = 0
16 for i in range(index+1,len(list)):
17 if list[i] < list[indexMin]: indexMin = i
18 if indexMin > index:
19 temp = list[index]
20 list[index] = list[indexMin]
21 list[indexMin] = temp
455def Sort(self):
456 r"""Sort(doubleArray self)"""
457 return _array.doubleArray_Sort(self)
27def 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
16def insertionSort2(list):
17 for index in range(0,len(list)-1):
18 value = list[index]
19 i = index
20 while(i > 0 and list[i-1] > value):
21 list[i] = list[i-1]
22 i = i - 1
23 list[i] = value
5def quick_sort(arr):
6 less = []
7 pivot_list = []
8 more = []
9 # 递归出口
10 if len(arr) <= 1:
11 return arr
12 else:
13 # 将第一个值做为基准
14 pivot = arr[0]
15 for i in arr:
16 # 将比急转小的值放到less数列
17 if i < pivot:
18 less.append(i)
19 # 将比基准打的值放到more数列
20 elif i > pivot:
21 more.append(i)
22 # 将和基准相同的值保存在基准数列
23 else:
24 pivot_list.append(i)
25 # 对less数列和more数列继续进行排序
26 less = quick_sort(less)
27 more = quick_sort(more)
28 return less + pivot_list + more
6def 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
111def sort(self, *args):
112 """
113 Sort the internal segment lists. The optional args are
114 passed to the .sort() method of the segment lists. This
115 can be used to control the sort order by providing an
116 alternate comparison function. The default is to sort by
117 start time with ties broken by end time.
118 """
119 self.valid.sort(*args)
120 self.active.sort(*args)

Related snippets