3G network and WiFi at the same time under Linux

Hi!

I run Ubuntu 12.10 at B-XM. There are two USB adapters connected: 3G and wifi. They work great, but I need similar functionality like in Android: if there is Wifi - connect to wifi, if no wifi- connect to 3G. Is it possible to tell the system to use any of available networks with preference to wifi?