📅  最后修改于: 2023-12-03 15:17:39.653000             🧑  作者: Mango
Minimum Sort, also known as Selection Sort, is a simple sorting algorithm that sorts an array by repeatedly finding the minimum element from unsorted part and putting it at the beginning.
def minimum_sort(arr):
n = len(arr)
for i in range(n-1):
min_index = i
for j in range(i+1, n):
if arr[j] < arr[min_index]:
min_index = j
arr[i], arr[min_index] = arr[min_index], arr[i]
return arr
arr = [5, 2, 8, 3, 1]
print(minimum_sort(arr))
Output:
[1, 2, 3, 5, 8]
Minimum Sort is a simple sorting algorithm that can be used for small arrays, but its time complexity makes it inefficient for large arrays or performance-critical applications. Other sorting algorithms, such as Quick Sort or Merge Sort, have better time complexity and are preferred in most cases.