(morphism, object_coords)
return (2, 0, default_sort_key(morphism))
Provides a morphism sorting key such that horizontal or
        vertical morphisms between neighbouring objects come
        first, then horizontal or vertical morphisms between more
        far away objects, and finally, all other morphisms.
Provides a morphism sorting key such that horizontal or
        vertical morphisms between neighbouring objects come
        first, then horizontal or vertical morphisms between more
        far away objects, and finally, all other morphisms.
Provides a morphism sorting key such that horizontal or vertical morphisms between neighbouring objects come first then horizontal or vertical morphisms between more far away objects and finally all other morphisms .
def _morphism_sort_key(morphism, object_coords):
        """
        Provides a morphism sorting key such that horizontal or
        vertical morphisms between neighbouring objects come
        first, then horizontal or vertical morphisms between more
        far away objects, and finally, all other morphisms.
        """
        (i, j) = object_coords[morphism.domain]
        (target_i, target_j) = object_coords[morphism.codomain]

        if morphism.domain == morphism.codomain:
            # Loop morphisms should get after diagonal morphisms
            # so that the proper direction in which to curve the
            # loop can be determined.
            return (3, 0, default_sort_key(morphism))

        if target_i == i:
            return (1, abs(target_j - j), default_sort_key(morphism))

        if target_j == j:
            return (1, abs(target_i - i), default_sort_key(morphism))

        # Diagonal morphism.
        return (2, 0, default_sort_key(morphism))
def _morphism_sort_key ( morphism , object_coords ) : ( i , j ) = object_coords [ morphism . domain ] ( target_i , target_j ) = object_coords [ morphism . codomain ] if morphism . domain == morphism . codomain : # Loop morphisms should get after diagonal morphisms # so that the proper direction in which to curve the # loop can be determined. return ( 3 , 0 , default_sort_key ( morphism ) ) if target_i == i : return ( 1 , abs ( target_j - j ) , default_sort_key ( morphism ) ) if target_j == j : return ( 1 , abs ( target_i - i ) , default_sort_key ( morphism ) ) # Diagonal morphism. return ( 2 , 0 , default_sort_key ( morphism ) )