[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: add'l 'sort -n' options
From: |
Paul Eggert |
Subject: |
Re: RFC: add'l 'sort -n' options |
Date: |
Mon, 06 Nov 2006 10:58:25 -0800 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Matthew Woehlke <address@hidden> 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.
- RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/03
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/04
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options,
Paul Eggert <=
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06