Much better solution.  Uses a sieve similar to Eratosthenes's to compute radicals quickly, then sorts from there.