Grouped selection lists

I have the Agile book and need to implement a grouped selection list. I
have studied the example on pg 360 but can’t fully understand enough to
get me up to speed with integrating it into my app (with a HABTM
relationship).

There seems to be no more info in the wiki or after much googling.

Can anyone help me out or point me in the right direction to getting
some examples etc??