स्यूडोकोड में एक एल्गोरिथ्म बनाएं जो चयन सॉर्ट विधि का उपयोग करके संख्याओं की एक सरणी को सॉर्ट करता है।ऐरे: [3, 1, 4, 7, 8, 2]
1. Initialize an empty list to store the sorted array.
2. While the input array is not empty, find the smallest element in the array.
3. Remove the smallest element from the input array and append it to the sorted list.
4. Repeat steps 2-3 until all elements have been added to the sorted list.
5. Return the sorted list.

Pseudo Code:

function selection_sort(array):
    sorted_array = []
    while array:
        smallest = array[0]
        for element in array:
            if element < smallest:
                smallest = element
        array.remove(smallest)
        sorted_array.append(smallest)
    return sorted_array

Example:

array = [3, 1, 4, 7, 8, 2]
sorted_array = selection_sort(array)
print(sorted_array)

Output:

[1, 2, 3, 4, 7, 8]