DEV Community

Hariprasath
Hariprasath

Posted on

Bubble Sort Got Bible

list = [3,1,2,4,2]

easiest sort algorithm ever seen

for i loop list {
    for j loop list - i {
       // i = 0
       // j = 0,1,2,3,4
       // this calculate the max value and push to last
       // eg [1,2,3,2,4]

       // second most 
       //i = 1
       // j = 0,1,2,3 // got max value so no use of last index
       // find second most
       // eg [1,2,2,3]
    }
} 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay