sorting programs rewritten