Comparative Analysis of Sorting Algorithms: TimSort Python and Classical Sorting Methods - Wibowo, Firmansyah Rekso; Faisal, Muhammad (Universitas Trilogi, 2024)
The sorted() function within the Python programming language has emerged as the primary choice among developers for sorting operations. Consequently, this study offers a comparative analysis of various classical sorting algorithms and Python's built-in sorting mechanisms, with the objective of identifying the most time-efficient sorting algorithm. The analysis involves assessing the time complexity of each algorithm while handling data arrays ranging from 10 to 1,000,000 elements using Python. These arrays are populated with randomly generated numeric values falling within the range of 1 to 1000. The benchmark algorithms utilized encompass Heap Sort, Shell Sort, Quick Sort, and Merge Sort. A looping mechanism is applied to each algorithm, and their execution speeds are gauged utilizing the Python 'time.perf_counter()' library. The findings of this study collectively indicate that Python's standard algorithm, surpasses classic sorting algorithms, including Heapsort, Shellsort, Quicksort, and Mergesort, in terms of execution.