--- title: "flip map()" slug: "basic-flip-map" updated: 2026-08-11T12:45:21Z published: 2026-08-11T12:45:21Z canonical: "docs.lobstersoftware.com/basic-flip-map" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # flip map() This function exchanges the key and the value for all key-value pairs in the map **a**. So the old value becomes the new key and the old key becomes the new value. > [!WARNING] > **IMPORTANT:** > > If key-value pairs with the same values exist, after calling the function the new key (created from the same old values) is occupied with the last new value (old key), since the previous ones are overwritten. The old keys (i.e. the new values) are sorted alphabetically in ascending order before being inserted into the "new" map. See examples. ## Parameters | Parameter | Description | | --- | --- | | a | Name of the map. | ## Examples Map "myMap" is filled with | Key | Value | | --- | --- | | key1 | value1 | | key2 | value2 | After calling the function, map "myMap" contains: | Key | Value | | --- | --- | | value1 | key1 | | value2 | key2 | If map "myMap" is filled with | Key | Value | | --- | --- | | key1 | value1 | | key2 | value1 | , map "myMap" will contain the following after the function call: | Key | Value | | --- | --- | | value1 | key2 |