Fix JIRA-983 and support exteranl sort for sortByKey

Change class ExternalAppendOnlyMap and make it support customized comparator function(not only sorted by hashCode).
If you replaced your `SortedExternalAppendOnlyMap`, you can revert all of these `protected`s to `private`s