In this example we want to merge lines based on the First Field of each line.
But we need to sort it first so it F1 and F2 lines are consecutive.

If your text is separated by a different character than semicolon separator replace -F";" by your separator or string. for example -F"," for a comma separated string.
It is case sensitive, if want it to be case insensitive add IGNORECASE = 1 but will not work well on some cases, if you need insenstivie case it would be better to up case or lower case all the text.

Example of merging lines based on first field, semicolon separated text