Q:

show all results on VLOOKUP

On Google sheets I wish to correlate data from a column, every time its adjacent column has a certain attribute. 
For example, Imagine I have a list of pupils and the language that they are studying.  In column A is the name of the pupil and in column B is the language:
NAME           |   LANGUAGE
---------------------------------------------------
John           |   French
James          |   Spanish
Stephen        |   Spanish
Simon          |   German
Mark           |   French
Luke           |   German
Robert         |   French

I want to generate a new sheet showing the name of each language, with the names of the people who study it in the adjacent columns.  It would look something like this:
LANGUAGE       |   NAMES
---------------------------------------------------
French         |   John     |  Mark     |   Robert
German         |   Simon    |  Luke     |  
Spanish        |   James    |  Stephen  |  

I have tried to achieve this with VLOOKUP however this only returns the first value encountered for each language, rather than all the values. 
What is the best way to achieve this? 

A:

Assuming 'French' is in cell A2 of Sheet2, in B2 you could try something like
=transpose(filter(Sheet1!$A$2:$A; Sheet1!$B$2:$B=$A2))

and fill down. 
(change ranges to suit).