Python Program Sort Elements In Array Ascending Order

    
        # Initialize an empty array
        array_of_elements = []

        # Get the number of elements you want in the array from the user
        elements = int(input("Enter the number of elements you want in the array: "))

        # Loop to take user input and add numbers to the array
        for i in range(elements):
            # Get the element from the user
            user_input = int(input(f"Enter element {i + 1}: "))

            # Add the number to the array
            array_of_elements.append(user_input)

        # Sorting the array in ascending order using sort()
        array_of_elements.sort()

        # Displaying the sorted array
        print("Sorted array:", array_of_elements)
    
Output:
    
        Enter the number of elements you want in the array: 5
        Enter element 1: 44
        Enter element 2: 23
        Enter element 3: 54
        Enter element 4: 16
        Enter element 5: 2
        Sorted array: [2, 16, 23, 44, 54]