How exactly does it work? If you had the list of numbers 4, 16, 3, 5, 21 then the image I have in my head would be the sort function going through the list a certain number of times until they are in ascending order, comparing each 2 adjacent elements as it goes.
So, upon the first time through the list it would be:
4 < 16
16 > 3 so swap them
16 > 5 so swap them
16 < 21
which would yield:
4, 3, 5, 16, 21 but then it would have to go through the list again. Is this how it works? Does it keep going through the list from start to finish until it has it right or does it somehow do it in one go?
Sorting is a subject in it's own right and there are a different number of sorting alorithms.
What you are thinking of is called the 'bubble sort' - it is what 99% of hyman beings would comeup with if asked to sort something - but it is abominably slooow.