Moved sort routine to the corresponding source/header file.