Restrict the sort key to an initial numeric string, consisting of
optional <blank> characters, optional minus-sign, and zero or more
digits with an optional radix character and thousands separators (as
defined in the current locale), which shall be sorted by arithmetic
value. An empty digit string shall be treated as zero. Leading zeros and
signs on zeros shall not affect ordering.
On the line "NUMBERS", the initial numeric string is empty, hence the
line is sorted with the value of 0.
+++ b/src/sort.c
@@ -1907,6 +1907,17 @@ numcompare (char const *a, char const *b)
while (blanks[to_uchar (*b)])
b++;
+ /* Put non-numeric keys before all numbers.
+ If both non-numeric, don't return 0 unless equal. */
+ if (!ISDIGIT(*a)&& *a != '-') {
Sorry, we can't take this patch, as it would violate POSIX and probably
break existing scripts that expect sort to treat non-numeric lines as
sorting identically with 0.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org