ArraySort_mod Module Reference

This module contains procedures for sorting arrays and merging sorted arrays. More...

Data Types

interface  isAscending
 Generate and return .true. if the input array is sorted in ascending order (with the possibility elements being equal), otherwise, generate and return .false.. More...
 
interface  isDescending
 Generate and return .true. if the input array is sorted in descending order (with the possibility elements being equal), otherwise, generate and return .false.. More...
 
interface  isSorted
 Return .true. if the input array is sorted, either ascending or descending, or all equal. More...
 
interface  merge
 Merge two ascending-sorted arrays such that the resulting merged array contains all elements of the two arrays in ascending order. More...
 
interface  operator(.merge.)
  Generate an ascending-sorted merger of the two ascending-sorted input arrays. More...
 
interface  sort
 Sort the input contiguous Array of rank 1 in ascending order, using a mixture of Quicksort algorithm (for large arrays) and selection-sort algorithm (for small arrays). More...
 
interface  sortBubble
 Sort the input contiguous Array of rank 1 in ascending order, using the Bubble sorting algorithm. More...
 
interface  sortDualPivotRecursive
 Sort the input contiguous Array of rank 1 in ascending order, using a mixture of merge-sort and Dual-Pivot Quicksort algorithms. More...
 
interface  sortHeap
 Sort the input contiguous Array of rank 1 in ascending order, using the Heapsort algorithm. More...
 
interface  sortHeapRecursive
 Sort the input contiguous Array of rank 1 in ascending order, using the recursive Heapsort algorithm. More...
 
interface  sortIndex
 Return the sorted indices of the input contiguous Array of rank 1 in ascending order using the Quicksort algorithm, such that Array(Index) will be in ascending order. More...
 
interface  sortInsertion
 Sort the input contiguous Array of rank 1 in ascending order, using the Insertion algorithm. More...
 
interface  sortInsertionBinary
 Sort the input contiguous Array of rank 1 in ascending order, using the Insertion algorithm with Binary search. The Binary search method yields better performance for larger input arrays. More...
 
interface  sortInsertionDouble
 Sort the input contiguous Array of rank 1 in ascending order, using the Double Insertion algorithm. The Binary search method yields better performance for larger input arrays. More...
 
interface  sortMergeRecursive
 Sort the input contiguous Array of rank 1 in ascending order, using a mixture of insertion-sort and merge-sort algorithms. More...
 
interface  sortRecursive
 Sort the input contiguous Array of rank 1 in ascending order, using a mixture of merge-sort and Quicksort algorithms. More...
 
interface  sortSelection
 Sort the input contiguous Array of rank 1 in ascending order, using the Selection sorting algorithm. More...
 
interface  sortShell
 Sort the input contiguous Array of rank 1 in ascending order, using the Shell sorting algorithm. More...
 

Variables

character(*, SK), parameter MODULE_NAME = "@ArraySort_mod"
 

Detailed Description

This module contains procedures for sorting arrays and merging sorted arrays.

Note
Recommended routines for sorting arrays:
  • The procedures under the generic interface sort are among the fastest sorting algorithms particularly for fully random input arrays.
Benchmarks:

Benchmark :: sorting

Here is a code snippet for a performance comparison of the different sorting algorithms in this module.
1! Test the performance of different sorting algorithms in ArraySort_mod.
2program benchmark
3
4 use Constants_mod, only: IK, RK
5 use Bench_mod, only: Bench_type
6
7 implicit none
8
9 logical :: issorted
10 integer(IK) :: i
11 integer(IK) :: iarr
12 integer(IK) :: fileUnitRandom
13 integer(IK) :: fileUnitSorted
14 integer(IK) , parameter :: NARR = 12_IK
15 integer(IK) , parameter :: NBENCH = 12_IK
16 integer(IK) :: ArraySize(NARR)
17 real(RK) , allocatable :: Array(:)
18 type(Bench_type) :: Bench(2,NBENCH)
21
22 Bench(1:2, 1) = Bench_type(name = "sort ", exec = sort , getOverhead = getOverhead)
23 Bench(1:2, 2) = Bench_type(name = "sortBubble ", exec = sortBubble , getOverhead = getOverhead)
24 Bench(1:2, 3) = Bench_type(name = "sortDualPivotRecursive ", exec = sortDualPivotRecursive , getOverhead = getOverhead)
25 Bench(1:2, 4) = Bench_type(name = "sortHeap ", exec = sortHeap , getOverhead = getOverhead)
26 Bench(1:2, 5) = Bench_type(name = "sortHeapRecursive ", exec = sortHeapRecursive , getOverhead = getOverhead)
27 Bench(1:2, 6) = Bench_type(name = "sortInsertion ", exec = sortInsertion , getOverhead = getOverhead)
28 Bench(1:2, 7) = Bench_type(name = "sortInsertionBinary ", exec = sortInsertionBinary , getOverhead = getOverhead)
29 Bench(1:2, 8) = Bench_type(name = "sortInsertionDouble ", exec = sortInsertionDouble , getOverhead = getOverhead)
30 Bench(1:2, 9) = Bench_type(name = "sortMergeRecursive ", exec = sortMergeRecursive , getOverhead = getOverhead)
31 Bench(1:2,10) = Bench_type(name = "sortRecursive ", exec = sortRecursive , getOverhead = getOverhead)
32 Bench(1:2,11) = Bench_type(name = "sortSelection ", exec = sortSelection , getOverhead = getOverhead)
33 Bench(1:2,12) = Bench_type(name = "sortShell ", exec = sortShell , getOverhead = getOverhead)
34
35 ArraySize = [( 2_IK**iarr, iarr = 3_IK, NARR + 2_IK )]
36
37 write(*,"(*(g0,:,' '))")
38 write(*,"(*(g0,:,' '))") "sort() vs. others."
39 write(*,"(*(g0,:,' '))")
40
41 open(newunit = fileUnitRandom, file = "main.random.out", status = "replace")
42 open(newunit = fileUnitSorted, file = "main.sorted.out", status = "replace")
43
44 write(fileUnitRandom ,"(*(g0,:,','))") "ArraySize", (Bench(1,i)%name, i = 1, NBENCH)
45 write(fileUnitSorted,"(*(g0,:,','))") "ArraySize", (Bench(2,i)%name, i = 1, NBENCH)
46
47 loopOverArraySize: do iarr = 1, NARR
48
49 allocate(Array(ArraySize(iarr)))
50 write(*,"(*(g0,:,' '))") "Benchmarking sorting algorithms with array size", ArraySize(iarr)
51
52 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 ! Time sorting algorithms against the default sort() procedures.
54 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55
56 issorted = .false.
57 do i = 1, NBENCH
58 call Bench(1,i)%time(Bench(1,i)%Timing)
59 end do
60 write(fileUnitRandom,"(*(g0,:,','))") ArraySize(iarr), (Bench(1,i)%Timing%Stat%mean, i = 1, NBENCH)
61
62 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 ! Time sorting algorithms with sorted input arrays against unordered input arrays.
64 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65
66 issorted = .true.
67 do i = 1, NBENCH
68 call Bench(2,i)%time(Bench(2,i)%Timing)
69 end do
70 write(fileUnitSorted,"(*(g0,:,','))") ArraySize(iarr), (Bench(2,i)%Timing%Stat%mean, i = 1, NBENCH)
71
72 deallocate(Array)
73
74 end do loopOverArraySize
75 write(*,"(*(g0,:,' '))")
76
77 close(fileUnitSorted)
78 close(fileUnitRandom)
79
80contains
81
82 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 ! sorting procedure wrappers.
84 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85
86 subroutine getOverhead()
87 call getArray()
88 end subroutine
89
90 subroutine getArray()
91 use Math_mod, only: genLinSpace
92 if (issorted) then
93 Array(:) = genLinSpace(0._RK, 1._RK, count = size(Array, kind = IK))
94 else
95 call random_number(Array)
96 end if
97 end subroutine
98
99 subroutine sort()
100 call getArray()
101 block; use ArraySort_mod, only: sort; call sort(Array); end block
102 end subroutine
103
104 subroutine sortBubble()
105 call getArray()
106 block; use ArraySort_mod, only: sortBubble; call sortBubble(Array); end block
107 end subroutine
108
109 subroutine sortDualPivotRecursive()
110 call getArray()
111 block; use ArraySort_mod, only: sortDualPivotRecursive; call sortDualPivotRecursive(Array); end block
112 end subroutine
113
114 subroutine sortHeap()
115 call getArray()
116 block; use ArraySort_mod, only: sortHeap; call sortHeap(Array); end block
117 end subroutine
118
119 subroutine sortHeapRecursive()
120 call getArray()
121 block; use ArraySort_mod, only: sortHeapRecursive; call sortHeapRecursive(Array); end block
122 end subroutine
123
124 subroutine sortInsertion()
125 call getArray()
126 block; use ArraySort_mod, only: sortInsertion; call sortInsertion(Array); end block
127 end subroutine
128
129 subroutine sortInsertionBinary()
130 call getArray()
131 block; use ArraySort_mod, only: sortInsertionBinary; call sortInsertionBinary(Array); end block
132 end subroutine
133
134 subroutine sortInsertionDouble()
135 call getArray()
136 block; use ArraySort_mod, only: sortInsertionDouble; call sortInsertionDouble(Array); end block
137 end subroutine
138
139 subroutine sortMergeRecursive()
140 call getArray()
141 block; use ArraySort_mod, only: sortMergeRecursive; call sortMergeRecursive(Array); end block
142 end subroutine
143
144 subroutine sortRecursive()
145 call getArray()
146 block; use ArraySort_mod, only: sortRecursive; call sortRecursive(Array); end block
147 end subroutine
148
149 subroutine sortSelection()
150 call getArray()
151 block; use ArraySort_mod, only: sortSelection; call sortSelection(Array); end block
152 end subroutine
153
154 subroutine sortShell()
155 call getArray()
156 block; use ArraySort_mod, only: sortShell; call sortShell(Array); end block
157 end subroutine
158
159end program benchmark
Sort the input contiguous Array of rank 1 in ascending order, using the Bubble sorting algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using a mixture of merge-sort and Dual-...
Sort the input contiguous Array of rank 1 in ascending order, using the recursive Heapsort algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using the Heapsort algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using the Insertion algorithm with Bina...
Sort the input contiguous Array of rank 1 in ascending order, using the Double Insertion algorithm....
Sort the input contiguous Array of rank 1 in ascending order, using the Insertion algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using a mixture of insertion-sort and m...
Sort the input contiguous Array of rank 1 in ascending order, using a mixture of merge-sort and Quick...
Sort the input contiguous Array of rank 1 in ascending order, using the Selection sorting algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using the Shell sorting algorithm.
Sort the input contiguous Array of rank 1 in ascending order, using a mixture of Quicksort algorithm ...
subroutine getOverhead()
Definition: main.f90:239
This module contains procedures for sorting arrays and merging sorted arrays.
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
Definition: Bench_mod.f90:51
This module contains the mathematical and programming constants.
integer, parameter IK
default integer kind in Fortran mode.
integer, parameter RK
default real kind in Fortran mode.
This module contains mathematical procedures.
Definition: Math_mod.f90:51
This is the class for creating benchmark and performance-profiling objects.
Definition: Bench_mod.f90:167

Example Unix compile command via GNU gfortran compiler
1#!/bin/bash
2gfortran -O3 -ffree-line-length-none -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_gnu_*.so -o main.exe
3./main.exe

Example Unix compile command via Intel ifort compiler
1#!/bin/bash
2ifort -standard-semantics -O3 -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_intel_*.so -o main.exe
3./main.exe

Postprocessing of the output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6
7fontsize = 15
8
9colnames = [ "sortBubble"
10 , "sortHeap"
11 #, "sortHeapRecursive"
12 #, "sortInsertion"
13 #, "sortInsertionBinary"
14 , "sortInsertionDouble"
15 , "sortMergeRecursive"
16 , "sortSelection"
17 , "sortShell"
18 , "sortDualPivotRecursive"
19 #, "sortRecursive"
20 ]
21
22dtypes = ["random", "sorted"]
23
24
25
26df = {}
27
28for dtype in dtypes:
29
30 df[dtype] = pd.read_csv("main.{}.out".format(dtype))
31
32 ax = plt.figure(figsize = 1.25*np.array([9.4,4.8]), dpi = 200)
33 ax = plt.subplot()
34
35 for colname in colnames:
36 plt.plot( df[dtype].values[:,0]
37 , df[dtype][colname].values / df[dtype]["sort"].values
38 , linewidth = 2
39 )
40
41 plt.xticks(fontsize = fontsize)
42 plt.yticks(fontsize = fontsize)
43 ax.set_xlabel("Array Size (# elements)", fontsize = fontsize)
44 ax.set_ylabel("Time normalized to sort() timing", fontsize = fontsize)
45 ax.set_title("Benchmarking of sorting algorithms compared to sort().\nInput data is " + r"$\mathrm{\bf{" + dtype + "}}$. Lower is better.", fontsize = fontsize)
46 ax.set_xscale("log")
47 ax.set_yscale("log")
48 plt.minorticks_on()
49 plt.grid(b = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
50 ax.tick_params(axis = "y", which = "minor")
51 ax.tick_params(axis = "x", which = "minor")
52 ax.legend ( colnames
53 , loc='center left'
54 , bbox_to_anchor=(1, 0.5)
55 , fontsize = fontsize
56 )
57
58 plt.tight_layout()
59 plt.savefig("benchmark.sorting.{}.png".format(dtype))
60
61
62
63ax = plt.figure(figsize = 1.25*np.array([9.4,4.8]), dpi = 200)
64ax = plt.subplot()
65
66colnames.append("sort")
67
68for colname in colnames:
69 plt.plot( df["random"].values[:,0]
70 , df["sorted"][colname].values / df["random"][colname].values
71 , linewidth = 2
72 )
73
74plt.xticks(fontsize = fontsize)
75plt.yticks(fontsize = fontsize)
76ax.set_xlabel("Array Size (# elements)", fontsize = fontsize)
77ax.set_ylabel("Sorting Time Ratio ( Sorted / Random Input Array )", fontsize = fontsize)
78ax.set_title("Sorted / Random input-arrays sorting-time ratio. Lower is better.", fontsize = fontsize)
79ax.set_xscale("log")
80ax.set_yscale("log")
81plt.minorticks_on()
82plt.grid(b = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
83ax.tick_params(axis = "y", which = "minor")
84ax.tick_params(axis = "x", which = "minor")
85ax.legend ( colnames
86 , loc='center left'
87 , bbox_to_anchor=(1, 0.5)
88 , fontsize = fontsize
89 )
90
91plt.tight_layout()
92plt.savefig("benchmark.sorting.random.sorted.ratio.png")

Visualization of the benchmark output

Benchmark :: sorting vs. indexing

The following program generates a performance comparison of the sort algorithm with sortIndex.
1program benchmark
2
3 use Constants_mod, only: IK, RK
4 use Bench_mod, only: Bench_type
5
6 implicit none
7
8 integer(IK) :: i,iarr
9 integer(IK) :: fileUnitRandom
10 integer(IK) :: fileUnitSorted
11 integer(IK) , parameter :: NARR = 12_IK
12 integer(IK) , parameter :: NBENCH = 3_IK
13 integer(IK) :: ArraySize(NARR)
14 real(RK) , allocatable :: Array(:)
15 integer(IK) , allocatable :: Index(:)
16 logical :: issorted
17 type(Bench_type) :: Bench(2,NBENCH)
18
19 Bench(:,1) = Bench_type("sort", sort, getOverhead)
20 Bench(:,2) = Bench_type("sortIndex", sortIndex, getOverhead)
21 Bench(:,3) = Bench_type("sortIndexWithSorting", sortIndexWithSorting, getOverhead)
22
23 ArraySize = [( 2_IK**i, i = 3_IK, NARR + 2_IK )]
24
25 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 ! Time the sort() against sortIndex for different array sizes.
27 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28
29 write(*,"(*(g0,:,' '))")
30 write(*,"(*(g0,:,' '))") "sort() vs. sortIndex."
31 write(*,"(*(g0,:,' '))")
32
33 open(newunit = fileUnitRandom, file = "main.random.out", status = "replace")
34 open(newunit = fileUnitSorted, file = "main.sorted.out", status = "replace")
35 write(fileUnitRandom,"(*(g0,:,','))") "ArraySize", (Bench(1,i)%name, i = 1, NBENCH)
36 write(fileUnitSorted,"(*(g0,:,','))") "ArraySize", (Bench(2,i)%name, i = 1, NBENCH)
37
38 loopOverArraySize: do iarr = 1, NARR
39
40 write(*,"(*(g0,:,' '))") "Benchmarking with array size", ArraySize(iarr)
41
42 allocate(Array(ArraySize(iarr)), Index(ArraySize(iarr)))
43
44 issorted = .false.
45 do i = 1, NBENCH
46 call Bench(1,i)%time(Bench(1,i)%Timing)
47 end do
48
49 write(fileUnitRandom,"(*(g0,:,','))") ArraySize(iarr), (Bench(1,i)%Timing%Stat%mean, i = 1, NBENCH)
50
51 issorted = .true.
52 do i = 1, NBENCH
53 call Bench(2,i)%time(Bench(2,i)%Timing)
54 end do
55
56 write(fileUnitSorted,"(*(g0,:,','))") ArraySize(iarr), (Bench(2,i)%Timing%Stat%mean, i = 1, NBENCH)
57
58 deallocate(Array, Index)
59
60 end do loopOverArraySize
61
62 close(fileUnitRandom)
63 close(fileUnitSorted)
64
65contains
66
67 subroutine getArray()
68 use Math_mod, only: genLinSpace
69 if (issorted) then
70 Array(:) = genLinSpace(0._RK, 1._RK, count = size(Array, kind = IK))
71 else
72 call random_number(Array)
73 end if
74 end subroutine
75
76 subroutine getOverhead()
77 call getArray()
78 end subroutine
79
80 subroutine sort()
81 block; use ArraySort_mod, only: sort; call sort(Array); end block
82 end subroutine
83
84 subroutine sortIndex()
85 block; use ArraySort_mod, only: sortIndex; call sortIndex(Array,Index); end block
86 end subroutine
87
88 subroutine sortIndexWithSorting()
89 block; use ArraySort_mod, only: sortIndex; call sortIndex(Array,Index); end block
90 Array(:) = Array(Index)
91 end subroutine
92
93end program benchmark
Return the sorted indices of the input contiguous Array of rank 1 in ascending order using the Quicks...

Example Unix compile command via GNU gfortran compiler
1#!/bin/bash
2gfortran -O3 -ffree-line-length-none -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_gnu_*.so -o main.exe
3./main.exe

Example Unix compile command via Intel ifort compiler
1#!/bin/bash
2ifort -standard-semantics -O3 -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_intel_*.so -o main.exe
3./main.exe

Postprocessing of the output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6
7fontsize = 15
8
9
10
11dtypes = ["random", "sorted"]
12
13for dtype in dtypes:
14
15 df = pd.read_csv("main.{}.out".format(dtype))
16
17
18
19 ax = plt.figure(figsize = 1.25*np.array([9.4,4.8]), dpi = 200)
20 ax = plt.subplot()
21
22 for colname in df.columns[1:]:
23 plt.plot( df.values[:,0]
24 , df[colname].values
25 , linewidth = 2
26 )
27
28 plt.xticks(fontsize = fontsize)
29 plt.yticks(fontsize = fontsize)
30 ax.set_xlabel("Array Size (# elements)", fontsize = fontsize)
31 ax.set_ylabel("Time [ seconds ]", fontsize = fontsize)
32 ax.set_title("Timing of sort() vs. sortIndex(). Input data is {}.\n Lower is better.".format(dtype), fontsize = fontsize)
33 ax.set_xscale("log")
34 ax.set_yscale("log")
35 plt.minorticks_on()
36 plt.grid(b = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
37 ax.tick_params(axis = "y", which = "minor")
38 ax.tick_params(axis = "x", which = "minor")
39 ax.legend ( df.columns[1:]
40 #, loc='center left'
41 #, bbox_to_anchor=(1, 0.5)
42 , fontsize = fontsize
43 )
44
45 plt.tight_layout()
46 plt.savefig("benchmark.sorting_vs_indexing.{}.png".format(dtype))
47
48
49
50 ax = plt.figure(figsize = 1.25*np.array([9.4,4.8]), dpi = 200)
51 ax = plt.subplot()
52
53 start = 0
54
55 plt.plot( df.values[:,0]
56 , np.ones(len(df.values[:,0]))
57 , linestyle = "--"
58 , linewidth = 2
59 #, color = "black"
60 )
61 for colname in df.columns[2:]:
62 plt.plot( df.values[start:,0]
63 , df[colname].values[start:] / df["sort"].values[start:]
64 , linewidth = 2
65 )
66
67 plt.xticks(fontsize = fontsize)
68 plt.yticks(fontsize = fontsize)
69 ax.set_xlabel("Array Size (# elements)", fontsize = fontsize)
70 ax.set_ylabel("Time Ratio ( sortIndex() / sort() )", fontsize = fontsize)
71 ax.set_title("Ratio of timing of sortIndex() to sort(). Input data is {}.".format(dtype), fontsize = fontsize)
72 ax.set_xscale("log")
73 #ax.set_yscale("log")
74 plt.minorticks_on()
75 plt.grid(b = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
76 ax.tick_params(axis = "y", which = "minor")
77 ax.tick_params(axis = "x", which = "minor")
78 ax.legend ( ["Equality Line"] + list(df.columns[2:])
79 #, bbox_to_anchor=(1, 0.5)
80 #, loc='center left'
81 , fontsize = fontsize
82 )
83
84 plt.tight_layout()
85 plt.savefig("benchmark.sorting_vs_indexing.{}.ratio.png".format(dtype))
86
87

Visualization of the benchmark output
The observed difference in the performance of sort vs. sortIndex is likely due to the current use of sortSelection and sortInsertion for small array sizes in sort and sortIndex, respectively.
Remarks
The sorting routines of this module are inspired by (but not the same as),
For details of naming abbreviations, see this page.
For details of the naming conventions, see this page.
This software is distributed under the MIT-license. If you use any parts or concepts originated from this library, please acknowledge the usage by citing the publications of the ParaMonte library.
Author
Amir Shahmoradi, April 21, 2017, 1:54 AM, ICES, The University of Texas at Austin

Variable Documentation

◆ MODULE_NAME

character(*,SK), parameter ArraySort_mod::MODULE_NAME = "@ArraySort_mod"

Definition at line 96 of file ArraySort_mod.f90.