[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"sort -nu" treatment of "0" & empty lines

From: Ulrich Hermisson
Subject: "sort -nu" treatment of "0" & empty lines
Date: Fri, 07 Jan 2005 16:44:08 +0100


the following behaviour of "sort -nu" needs not necessarily be considered a bug:

$ echo ",2,0,1,-2,3,-4" | tr "," "\n" | sort -nu


This means: An empty line (and likewise: a line not starting with a number) is interpreted as having the key "0". Since it occurs before the line starting with "0" here, the latter is missing in the output, which contains the empty line instead. So one may think that the key "0" does not appear in the
input, even more so if there are no keys with negative numbers.

Possible solutions: Interpret empty lines (and lines not starting with a number) as having the key plus or minus infinity, or leave it as it is, mentioning the chosen convention in the documentation.
Thank you!

With kind regards
Ulrich Hermisson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]