added pointer comparing function for sorting