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

Discuss the need of new professional profile of teaching staff in order to survive in this competitive era.

Why Google stopped showing the card of summary of your site's performance on Google Search ?

Global Scholarship Opportunities for 2025 – Fund Your Education Abroad

Warning! Avoid Fraudulent Job Offers

بزرگ شہریوں کے لیے چہرے کی شناخت کی ٹیکنالوجی متعارف

Personality development occurs in life but later years provides an opportunity for the modification of previously development trends. Discuss.

پاکستانی ڈاکٹر کو کینیڈا کے بڑے سول اعزاز 'آرڈر آف کینیڈا "سے نواز دیا گیا

Use a dictionary where keys are student names and values are lists of 3 marks Using Python

Inspector ASF Seats announced through FPSC 2025

International Scholarship without IELTS 2025