ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
Language/ LibraryMethodIn-place or Return a CopyArgument to Switch Sort Order to DescendingType of SortOther ArgumentsNotesDefault Axis
2
Python (vanilla)my_list.sort()In-place reverse = TruetimsortkeyFor lists only.n/a
3
Python (vanilla)my_list = sorted(my_iterable)Copyreverse = TruetimsortkeyFor any iterable.n/a
4
Numpymy_ndarray.sort()In-place n/a - do outside with [::-1]Default is quicksort. Alternative options: kind : ‘mergesort’, ‘heapsort’, ‘stable’.axis=-1, kind='quicksort', order=None.Quicksort is now introsort, which becomes heapsort if slow. Stable is mapped to mergesort. Mergesort doesn't use a mergesort. It uses timsort or radix sort under the hood, depening upon the data type.last axis
5
Numpynp.sort(my_array)Copyn/a - do outside with [::-1]Default is quicksort Alternative options: kind : ‘mergesort’, ‘heapsort’, ‘stable’.axis=-1, kind='quicksort', order=None.Quicksort is now introsort, which becomes heapsort if slow. Stable is mapped to mergesort. Mergesort doesn't use a mergesort. It uses timsort or radix sort under the hood, depening upon the data type.last axis
6
Pandasdf = df.sort_values(by='my_column')Copy (unless inplace=True)ascending = FalseDefault is numpy quicksort. Alternative options: kind : ‘mergesort’, ‘heapsort’, ‘stable’. by, axis=0, inplace=False, kind='quicksort', na_position='last.For DataFrame and Series. Uses Numpy for sorting under the hood.last axis
7
TensorFlowtf.sort(my_values)Copydirection = 'DESCENDING'Finds the largest value in the tensor using top_k(). Uses CUB Cuda library, which wraps thrust, for parallel sort with GPU for large cases; algorithms vary - e.g. merge sort, radix sort.last axis
8
PyTorchtorch.sort(my_values)Copydescending = TrueUses thrust CUDA library for parallel sort with GPU for large cases; algorithms vary - e.g. merge sort, radix sort.last axis
9
SQLORDER BY my_columnCopyDESCVaries. Postgres uses a disk merge sort, quick sort, or heap sort depending upon the situation.n/a
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100