Repository: vacanza/python-holidays

Issue:
Holiday names sorting
While I was working on Bolivia holidays one of my tests caught an error with holiday names when two holidays fall on the same day. In this particular case it was one regional holiday (La Tablada in Tarija) and Viernes Santo holiday. In 2022 they both fell on Apr 15, so I had to make a separate test for [this case](https://github.com/dr-prodigy/python-holidays/blob/beta/test/countries/test_bolivia.py#L60). But to test it I needed to know the logic behind how names are combined.

I checked the [code](https://github.com/dr-prodigy/python-holidays/blob/beta/holidays/holiday_base.py#L350) and noticed that there was no "rule" for holiday names order in such cases, and that makes testing much harder. 

@dr-prodigy  Would it be ok to submit a PR with a change to this fundamental logic? 


Discussion:

Resolving patch:
diff --git a/holidays/holiday_base.py b/holidays/holiday_base.py
--- a/holidays/holiday_base.py
+++ b/holidays/holiday_base.py
@@ -349,11 +349,14 @@ def __getitem__(self, key: DateLike) -> str:
 
     def __setitem__(self, key: DateLike, value: str) -> None:
         if key in self:
-            if self.get(key).find(value) < 0 and value.find(self.get(key)) < 0:
-                value = f"{value}, {self.get(key)}"
-            else:
-                value = self.get(key)
-        return dict.__setitem__(self, self.__keytransform__(key), value)
+            # If there are multiple holidays on the same date
+            # order their names alphabetically.
+            delimiter = ", "
+            holiday_names = set(self.get(key).split(delimiter))
+            holiday_names.add(value)
+            value = delimiter.join(sorted(holiday_names))
+
+        dict.__setitem__(self, self.__keytransform__(key), value)
 
     def update(  # type: ignore[override]
         self, *args: Union[Dict[DateLike, str], List[DateLike], DateLike]


Test patch:
diff --git a/test/countries/test_brazil.py b/test/countries/test_brazil.py
--- a/test/countries/test_brazil.py
+++ b/test/countries/test_brazil.py
@@ -282,7 +282,7 @@ def test_TO_holidays(self):
         to_holidays = holidays.BR(subdiv="TO")
         self.assertIn("2018-01-01", to_holidays)
         self.assertEqual(
-            to_holidays[date(2018, 1, 1)], "Instalação de Tocantins, Ano novo"
+            to_holidays[date(2018, 1, 1)], "Ano novo, Instalação de Tocantins"
         )
         self.assertIn("2018-09-08", to_holidays)
         self.assertEqual(
diff --git a/test/test_holiday_base.py b/test/test_holiday_base.py
--- a/test/test_holiday_base.py
+++ b/test/test_holiday_base.py
@@ -13,11 +13,10 @@
 import sys
 import unittest
 import warnings
-
 from datetime import date, datetime, timedelta
-from dateutil.relativedelta import relativedelta, MO
 
 import holidays
+from dateutil.relativedelta import MO, relativedelta
 
 
 class TestBasics(unittest.TestCase):
@@ -261,7 +260,7 @@ def test_add(self):
         )
         na = holidays.MX() + holidays.CA() + holidays.US()
         self.assertEqual(
-            na.get(date(1969, 12, 25)), "Navidad [Christmas], Christmas Day"
+            na.get(date(1969, 12, 25)), "Christmas Day, Navidad [Christmas]"
         )
 
     def test_get_list(self):
@@ -270,12 +269,12 @@ def test_get_list(self):
         wild = westland + chathams
         self.assertEqual(
             wild[date(1969, 12, 1)],
-            ("West Coast Anniversary Day, Chatham Islands Anniversary Day"),
+            ("Chatham Islands Anniversary Day, West Coast Anniversary Day"),
         )
 
         self.assertEqual(
             wild.get_list(date(1969, 12, 1)),
-            ["West Coast Anniversary Day", "Chatham Islands Anniversary Day"],
+            ["Chatham Islands Anniversary Day", "West Coast Anniversary Day"],
         )
         self.assertEqual(wild.get_list(date(1969, 1, 1)), ["New Year's Day"])
         self.assertEqual(