For general photography both of these are good but Nikon D5100 has an edge in low light performance.
For macro photography and distant subject photography (Plus Wildlife photography) , you'll need good lenses instead of a good camera. Macro lenses don't cost much but telephoto lenses cost a lot.
If you are interested in sports photography the A57 is a good choice because of its high speed frame rate. (12 fps).
For night sky or astrophotography you'll need a special camera such as the Canon 60Da (a variant of the Canon 60D) which is specifically built for Astrophotography.
All the cameras these days that I find on the net have a 30s long exposure limit. But having a "bulb" function like the one on the Sony A77 will fulfill the requirements of long exposure shots.
As far as your question is concerned, I think both the cameras have some +ve points as well as -ve points.
If you can't decide with your brain then follow your heart. Good luck.

