How do I stop longing?

I would like to know if anyone has been able to stop or handle the constant though/feeling of longing. For context, I (30m) came out 11 months ago in an effort to turn my life around. Did not help. I have never had a relationship, nor barely any experience with a guy. Whenever a see a couple, specially holding hand, I just get sad. When I'm watching a movie/show or reading a book and there is sex, I simply hate it. I used to fantasize with maybe that will happen, but it's getting clearer that won't happen. I am trying to live a life outside that longing, but I can't. I go to the gym and I literally have no energy to do anything. I barely leave my house any more. This thing is affecting every part of my life. I have accepted it won't happen. No love, no affection. But my mind cannot move from it. I am trying to find some exercises or mindset, so I can improve my life outside of that missing aspect. What can I do? Any advice?