def METHOD_NAME(profiler: cProfile.Profile, sort_order: pstats.SortKey) -> str:
    stream = io.StringIO()
    ps = pstats.Stats(profiler, stream=stream).sort_stats(sort_order.value)
    _fix_fcn_list(ps)
    ps.print_stats()
    return stream.getvalue()