Added sorting of the portals list. Added some comments to make the code more readable