Can you explain selection sort in detail?