Folks. I figured out the problem, but I can't figure out why it would give me an error. If I don't take the acos of $d, and just multiply (180/3.14159)*$d, then I can sort normally. Can anyone explain to me why the acos() function would be screwing up my sort?