0
for(int j=0;j<n;j++){
        for(int k=j;k<n;k++){
            if(array[j]>array[k]){
                int temp = array[k];
                array[k]=array[j];
                array[j]=temp;

            }

            }
        }

//How does it works? I mean I solved but I am still confused.

1 Answer 1

1

This is a bubble sort. See https://en.m.wikipedia.org/wiki/Bubble_sort for an explanation of this simple approach to sorting data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.