Its a simple solution to sort a portal with desire flagging. Here its a Contacts and contacts address relationship database where this files give a solution for following objectives:
1. Only One Address can be the primary address with all the other ones automatically flagged as Secondary.
2. When the first Address is created, it is automatically flagged as a primary address.
3. If there are multiple addresses, only one can be Primary.
4. When an address is changed to primary, all the other addresses related to the particular contact must be changed to secondary.
5. When viewing the related addresses within a Portal in the contact Database, They must be sorted so that the primary address is always on top