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

Bank Alfalah Management Trainee Program and Summer Internship Program 2025

فلم پی کے میں دکھایا گیا ایک سین حقیقت میں تبدیل

Elucidate the role of public and private sector in elementary education. Discuss the role of government of Pakistan in this context.

Palm Reading in Islam : Is It Permissible? A Faith-Centered Guide

10-Day PhD Interview Prep Series: Essential Questions & Answers

Ask user for an item and check whether it exists in a given tuple or not using Python

Explain the concept of economics of higher education in Pakistan. What are different ways of financing higher education in Pakistan?

Rescue 1122 Punjab Jobs 2025 For Multiple Categories

NIU - NUR International University - Admission Process

Monitoring and Evaluation Officer Jobs in Punjab