added some code fragments for sort and swap algorithm