NCDEX interview question

Write a code for bubble sort and explain it