Add documentation to swap algorithm