Fix JIRA-983 and support exteranl sort for sortByKey

Change class ExternalAppendOnlyMap and make it support customized comparator function(not only sorted by hashCode).
This place might be the performance hot place, since we need to reconstruct each tuple. But for current hash map implementation, seems no better solutions to avoid this. I think we should figure out the performance of this manipulation.