created sorting algo for assignment