patch 8.2.3910: when compare function of sort() fails it does not abort

Problem:    When the compare function of sort() produces and error then sort()
            does not abort.
Solution:   Check if did_emsg was incremented.
diff --git a/src/list.c b/src/list.c
index 6fafef6..838991b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1919,6 +1919,7 @@
     char_u	*func_name;
     partial_T	*partial = sortinfo->item_compare_partial;
     funcexe_T	funcexe;
+    int		did_emsg_before = did_emsg;
 
     // shortcut after failure in previous call; compare all items equal
     if (sortinfo->item_compare_func_err)
@@ -1946,7 +1947,7 @@
     clear_tv(&argv[0]);
     clear_tv(&argv[1]);
 
-    if (res == FAIL)
+    if (res == FAIL || did_emsg > did_emsg_before)
 	res = ITEM_COMPARE_FAIL;
     else
     {