Inspiration

Write a script to sort a list

Question on LHD:Build

Tackle this classic computer science project in any fashion you’d like. You don’t need to sort the list of Devposts, though - here’s a link to the Day 5 one.

Code, in python:

n1 = int(input("Enter number of elements : ")) a = list(map(int,input("\nEnter the numbers : ").strip().split()))[:n1] def sorta(a): n=len(a) for j in range(0, n-1): for i in range(n-j-1): if a[i] > a[i+1]: a[i],a[i+1]=a[i+1],a[i] print(a) sorta(a)

Built With

Share this project:

Updates