implemented sort for magnets and obstacles

magnets and obstacles are now stored in ascending order by position.X.