I deal with exactly the same problem and the approach is same as explained by @relentless
- Find all the associations of the current user
- Sort by number of likes
However this looks very good in theory, but in practice in my case it required more time than the user was willing to wait.
So what I did is that I limited the number of the database records (posts and events in your case) to some amount that can be processed in like 2 second time-frame. In my case this was 6 months in the past, but in your case you have to tune the timing and the load to best suit your needs.