Discussions Events Study Material Jobs
Sort a List Manual Bubble Sort using Loops in Python - Uniwaly

Explore Diverse Conversations

Sort a List Manual Bubble Sort using Loops in Python

Posted By: UmairMehmood Published On: 13 June 2025 At: 12:28 PM

Sort a list of numbers in ascending order using a loop (no built-in sort)
numbers = [5, 2, 9, 1, 7, 3]
n = len(numbers)

for i in range(n):
    for j in range(0, n - i - 1):
        if numbers[j] > numbers[j + 1]:
            numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
print("Sorted list in ascending order:", numbers)


Tags:

python bubble sort in python bubble sort
Login to like

Posted By:

Author Profile

UmairMehmood

11 days ago

Join the conversation!

Login to Comment

Discover More Articles

Print All Even Numbers in a List using while loop in Python

Directorate of Electronic Media & Publications jobs in 2025 apply online

Punjab Higher Education Commission PHEC Jobs 2025

Find the Largest Among Three Numbers Using Python

NIU - NUR International University - Admission Process

PPSC Jobs - Male and Female Assistant Registrar Cooperative Societies 2025

INSPECTORATE OF MINES, PUNJAB, MINES & MINERALS DEPARTMENT 2025 - 14/2025

National University of Computer and Emerging Sciences Admission Process

Superior University Admission Process

Pakistan Bait ul Mal Jobs 2025 - Apply Now