bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] asort 3rd argument does not work as documented


From: Andrew J. Schorr
Subject: [bug-gawk] asort 3rd argument does not work as documented
Date: Fri, 8 Nov 2013 12:49:01 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

In doc/gawk.texi, it says:

   The optional third argument @var{how} is a string which controls the rule
   for comparing values, and the sort direction.  A single space is required
   between the comparison mode, @samp{string} or @samp{number}, and the
   direction specification, @samp{ascending} or @samp{descending}.  

I tried using asorti with "number ascending", and I got a fatal error:

gawk: cmd. line:35: (FILENAME=- FNR=182) fatal: `number ascending' is invalid 
as a function name

Based on inspection of the source code, it seems that the actual 3rd argument
should be one of the PROCINFO["sorted_in"] values, such as "@val_num_asc".

So it seems that there is either a documentation bug, or the code should
be enhanced to support these more user-friendly values for describing the
sort function.

In this context, it is easy to be confused about whether to use "@ind_num_asc"
or "@val_num_asc", so it would be nice to implement the documented behavior.
By experimentation, I found that "@val_num_asc" for my asorti case where I
want "number ascending".

Regards,
Andy



reply via email to

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