Sort function lib for harpe