Matthew Woehlke <[EMAIL PROTECTED]> writes:

> Paul Eggert wrote:
>> Matthew Woehlke writes:
>>> '-N _options_, --numeric-sort=_options_'
>> The other sort options can be attached to -k; how would this work
>> here?
>
> Sorry, I'm not sure I understand what you mean by this comment. What
> would be attached to -k, and how?

For example, "sort -k2,2n -k3,3g" says sort numerically in column 2,
breaking ties with a general numeric sort in column 3.

>>> 'a': convert numbers with strtol(,0) (i.e. automatically recognize
>>> '0x<num>' (hex), '0<num>' (octal).
>>> 'o': all numbers are octal, i.e. strtol(,8)
>>> 'x': all numbers are hexadecimal, i.e. strtol(,16)
>> These shouldn't use strtol; they should work regardless of the size
>> of the number, just as it already works for decimal numbers.
>
> I was actually wondering about that... from the info page it sounded
> like strtod is actually used,

It is, for -g.  But strtol is not used for ordinary numeric sort.

Ideally, we wouldn't use strtod even for -g.  We would do exact
comparison, so that, e.g., 1.0000000000000000000000000000000000000000001
would compare greater than 1.0 (as it already does for -n).  That
would be some more work, but it shouldn't be _that_ much work.

> (I guess this means you would always convert numbers to [long]
> doubles?)

No, you compare the strings directly, without converting to integer or
double.  That is how the existing code works for -n.

> do you think these would be good ideas?

Yes, it sounds reasonable.  However, a patch like that would be
a nontrivial change, so we'd need copyright papers from you in order
to install it.  Have you started the ball rolling on this?  If not,
please contact me privately.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to