josephus algorithm and three sort algorithms