A person must be exceedingly careful to not be happy concerning the downfall of his fellow and of his being shamed, as is written [in sefer “Mishlei”], “Do not be happy at the downfall of your enemy, and your heart should not rejoice when he stumbles, lest HaShem sees and it will be evil in His Eyes…” (Mishlei: 24; 17 – 18) This sin [of rejoicing at the downfall of one’s fellow], greatly arouses the power of [the attribute of] justice [against this] person [who rejoiced], and within [this sin exists] the power to cause destruction, precisely as [is the case with] the sin of idolatry, as we find in the [teachings] of our Sages of Blessed Memory (Eichah Rabbasi, chapter 1, sif 20). [We learn in “Eichah Rabbah” that] “…at the time of the destruction of The Beis HaMikdash, upon Avraham Avinu’s entrance into The Beis HaMikdash, The Holy One, Blessed is He, asked him: “What [is the] reason [that] My loved one in My House?” [Thereupon, Avraham] responded, [as follows]: “For what reason have my children been exiled into the midst of the nations of the world?” The Holy One, Blessed is He, [then] responded to [Avraham]: “[Your children have been put into exile] because they worshipped idols, and are happy at one another’s downfall…”” Behold, [it is evident from this teaching in “Eichah Rabbah”] that The Holy One, Blessed is He, compared [the] sin [of rejoicing at the downfall of one’s fellow Jew], to [the sin of] idolatry. Rather, [instead of rejoicing at the downfall of one’s fellow], the individual should constantly contemplate concerning himself, that based upon [the] sins [which he has performed] and his deficiencies, he is also fitting to be shamed and scorned, rather, The Holy One, Blessed is He, has mercy on him in the merit of his forefathers.
 The gemara in maseches “Shabbos” (149b) bases the teaching that evil does not dwell in HaShem’s abode on the pasuk from “Tehillim”, which states, “For You are G-d Who does not desire evil, evil will not dwell in Your abode.”
 In this pasuk, we see that Dovid HaMelech requested of HaShem to bring that which is good upon those who are good in that they act good (RaDa”K) and who are upright in their heart in that they are honest and avoid deception (Metzudas David).
 These p’sukim from sefer “Mishlei”, read as follows:
“Do not be happy at the downfall of your enemy and do not [allow] your heart to rejoice when he stumbles. Lest HaShem Sees and it will be evil in His Eyes and He shall cause His Anger to return from upon him.” (Mishlei: 24; 17 – 18)
Ibn Ezra explains that a person should be cautious to not be happy when his enemy experiences misfortune, even if it comes about by The Decree of HaShem. The Ibn Ezra explains that a person should not be happy even when his enemy is punished by HaShem, for HaShem does not want the person to be happy when HaShem takes retribution against this other individual. If someone is happy when his enemy stumbles, since he did not have mercy on the suffering of the other person, HaShem can overturn the negative decree against that person and caused the person who rejoiced at the suffering of his enemy to experience that suffering.
The above applies to one’s enemy who is not an evildoer. However, as we learn in “Mishlei” and at the end of maseches “Sanhedrin”, one does rejoice at the downfall of the evildoers. Therefore one may only rejoice at the downfall of his enemy if that enemy is also an evildoer, as is evident at the demise of the Egyptian army in the Red Sea. At that time, The B’nei Yisrael praised HaShem for saving them from their evil Egyptian enemy and for causing the downfall of these evildoers. (Shmos: 14; 28 – 15; 21)
The gemara by the conclusion of maseches “Sanhedrin”, states:
“When an evildoer is destroyed from the world, good comes to the world, as it says [in “Mishlei”], “…and with the destruction of evildoers [comes] joy.” (11; 10)
 The entire passage from “Eichah Rabbah” (the Vilna version), is written below:
““…a princess of the countries.” (Eichah: 1; 1) Rabbi Yochanan said, ‘since [The B’nei] Yisrael violated the condition that they accepted from Sinai, therefore they were a tributary. Sinai – סיני – and “as a tributary” – למס – are one and the same, the numerical equivalent [of סיני] being equivalent to the numerical value [of למס].’ Rabbi Yishmael, the son of Nachman, said, ‘As a consequence of [The B’nei] Yisrael worshipping idols, they therefore became a tributary, the numerical equivalent of [the word] “למס” – “as a tributary” being equivalent to [the word] “סמל” – “form [of an idol]”, the arrival of [idol worship] leads to [Israel becoming a tributary].’ Rav Birechiah said, ‘the reverse [spelling] of “למס” – “as a tributary” is “סמל” – “form [of an idol]”’. The Rabbis have said, ‘“למס” – “as a tributary” is “מסא דליבא” – “melting of the heart”.’ Rav Ukva said, ‘On the night of Tisha B’Av (The Ninth of Av), Avraham Avinu entered The Holy of Holies [in The Beis HaMikdash] and grasped onto HaShem’s Hand and was taking long and short walks [in The Holy of Holies. Thereupon], The Holy One, Blessed is He, said to him, ‘What reason is My loved one in My House?’ (Yirmiyahu: 11; 15) [Whereupon, Avraham Avinu] said to Him, ‘My Master, where are my children?’ [HaShem] said to him, ‘They have sinned and have been exiled in the midst of the nations.’ [Avraham Avinu] said to Him, ‘There weren’t righteous individuals in their midst [who would have rescued them from being exiled]?’ [HaShem] said to him, ‘…They have performed [in accordance with] their evil intents…’ (Yirmiyahu: 11; 15) (MaHaR”I Kra) [Thereupon, Avraham] said to [HaShem], ‘You should have focused on the good individuals in their midst.’ [HaShem] said to him, ‘Their multitudes were evil, as it is written, “…the masses have performed [in accordance with] their evil intents…”’ (Yirmiyahu: 11; 15) [Avraham] said to Him, ‘You should have focused Your attention at the bris milah (circumcision) that is in their flesh.’ [HaShem] said to [Avraham], ‘By your life, they rejected [the bris milah], as it says, “…and your holy flesh you have passed from upon yourselves…” (Yirmiyahu: 11; 15) Not only [did they reject the bris milah], but they were [also] happy at each others downfall, as it is written, “…for [at the time you performed] your evil [actions], you have then rejoiced.” (Yirmiayhu: 11; 15), and it is written “…one who is happy at the misfortune [of another] will not be cleansed.”’ (Mishlei: 17; 5) (Metzudas David)
For what reason is the scroll of Kinos (Lamentations) read in the order of the Aleph-Beis? Rabbi Yehuda, Rabbi Nechamiah, and the Rabbis [offer answers]. Rabbi Yehuda says, [the reason that the scroll of “Kinos” is written in alphabetical order] follows that which is written [in sefer “Daniel”, as follows]: “And all of [The People of] Israel have violated Your Torah…” (Daniel: 9; 11), which is written from Aleph to Tav, therefore, this scroll [of “Kinos”, which discusses many of the misfortunes the Jewish People suffered at the time of the destruction of The Beis HaMikdash and Yirushalayim], is written in alphabetical order, to correspond to [The Torah which was violated].
Rabbi Nechemiah says, ‘Even though Yirmiyahu reduced [the Aleph-Beis through] “Eichah”, Yishayahu preceded [Yirmiyahu and] healed every single pasuk of [the Aleph-Beis] through “תבוא כל רעתם...”, [the last pasuk of the first chapter of “Eichah”, which begins with tav, the last letter of the Aleph-Beis.]’”
This teaching, with some variations, can be found in maseches “Minachos” (53b) and likewise in “Yalkut Shimoni” on sefer “Yirmiyahu”, Remez 288.