def compareSegmentLength(endpoint, otherEndpoint):
 if (endpoint.segmentLength > otherEndpoint.segmentLength):
  return 1
 if (endpoint.segmentLength < otherEndpoint.segmentLength):
  return (-1)
 return 0

def compareSegmentLength ( endpoint , otherEndpoint ) : if ( endpoint . segmentLength > otherEndpoint . segmentLength ) : return 1 if ( endpoint . segmentLength < otherEndpoint . segmentLength ) : return ( - 1 ) return 0
get comparison in order to sort endpoints in ascending order of segment length .