added support to set the comparison function externally. removed internal implementation.
Merge branch 'dev_cmpfunc' into dev