bug-gawk
[Top][All Lists]
Advanced

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

Re: can a and d be the same for asort?


From: arnold
Subject: Re: can a and d be the same for asort?
Date: Tue, 06 Jul 2021 01:40:04 -0600
User-agent: Heirloom mailx 12.5 7/5/10

This is a valid documentation issue. Using the same array for both
source and dest is a no-op, but is needed in the case where you
supply the third argument.

I will update the manual and the man page and add a lint warning
for when the same array is passed for source and destinatin but
no third argument is passed.

Thanks,

Arnold

Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> https://www.gnu.org/software/gawk/manual/html_node/Array-Sorting-Functions.html
>
> It is not clear whether it is OK to make s and d be the same array.
> Should they never be the same in order for asort to work? If so,
> should this be clearly stated? If not, it should also be mentioned to
> make it clear.
>
>        asort(s [, d [, how] ]) Return  the  number of elements in the
> source array s.  Sort the contents of s using gawk's normal rules for
> comparing values, and
>                                replace the indices of the sorted
> values s with sequential integers starting with 1. If the optional
> destination array d is speci-
>                                fied, first duplicate s into d, and
> then sort d, leaving the indices of the source array s unchanged. The
> optional string how con-
>                                trols the direction and the comparison
> mode.  Valid values for how are any of the strings valid for
> PROCINFO["sorted_in"].  It can
>                                also be the name of a user-defined
> comparison function as described in PROCINFO["sorted_in"].
>
> -- 
> Regards,
> Peng



reply via email to

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