Rearanges javascript