Instead of Array, you can use collections. and use the sort method of collections.
By the way, I used double in that problem, and it works fine.

--- updated ---
Correction. There is a sort...