Sortable groups and elements between groups

Hello.

I need to implement something like this:
http://www.gregphoto.net/sortable/advanced/
but i can’t understand, how to do it.

I don’t need adding new group actually, but I need sorting items into
the group, moving its between groups and sorting whole groups.

Does anybody have the complete solutions on ror?

Thank you.