def sortkey(item):
 return (type(item).__name__, item)

def sortkey ( item ) : return ( type ( item ) . __name__ , item )
sorting key function that is robust to different types both strings and tuples are common key types in dask graphs .