Here's how to display two listings side by side in a figure using the subfig and lstlistings packages.
First, put the code you want to display in 2 files (say a and b). Then do the following:
\begin{figure}
\subfloat[subcaption 1]{\lstinputlisting{a}}
\hspace{20pt}
\subfloat[subcaption 2]{\lstinputlisting{b}}
\caption{Global caption}
\end{figure}
This way you obtain the listing side by side. The only issue is that their vertical align is centered. So if the height of the two listings is not the same, the short one is not vertically aligned to the long one.
One way to solve this issue is to use \raisebox{xxpt}{\subfloat[...]{...}} where xx is how much points you want to raise the listing. Anyway I found the result not good enough.
Googling a little bit I found something on the faq section of subfig'sdocumentation. Here it is:
6.1 "My sub-floats are not aligned along their bottoms. Why?"
Remember! The subfig package aligns sub-floats along their baselines with the sub- caption (if any) sticking out above or below. The above problem is usually due to using a minipage, tabular or array environment that, by default, places the baseline at the center of the box that it generates. If the two sub-floats are different sizes, or if onesub-float is generated in some other way with its baseline not at the expected place (perhaps an \includegraphics), then the sub-float will be misaligned. One solution is to use the environment options `[t]' or `[b]' to move the baseline to the top or bottom rather than the center.
I tried (not that hard to be honest), but I wasn't able to align both figure to the top. After all I think I'll keep the center valign...