patch 9.0.1396: sort(list, 'N') does not work in Vim9 script context
Problem: sort(list, 'N') does not work in Vim9 script context.
Solution: Convert string to number without giving an error. (closes #12061)
diff --git a/src/list.c b/src/list.c
index ae9e3e9..991be8b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1910,8 +1910,8 @@
if (sortinfo->item_compare_numbers)
{
- varnumber_T v1 = tv_get_number(tv1);
- varnumber_T v2 = tv_get_number(tv2);
+ varnumber_T v1 = tv_to_number(tv1);
+ varnumber_T v2 = tv_to_number(tv2);
return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
}
@@ -2831,7 +2831,7 @@
}
else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == VAR_DICT)
{
- // Check that extend() does not change the type of the list if it was
+ // Check that extend() does not change the type of the dict if it was
// declared.
if (!is_new && in_vim9script() && argvars[0].vval.v_dict != NULL)
type = argvars[0].vval.v_dict->dv_type;