changed sort method
Added explicit type cast