patched cast warnings in Sort.cpp