Menu thing

Does anyone have any tips on how to do this menu idea? The way when you click on one of the categorys it puts it in the top and if you click another it switches and sort of knows where it all is and moves it around.
like here