Hi,
the reason is roughly this:
In GNU APL there is an order between *all* APL values, not only between
numeric vectors
or character vectors. The order should also include nested APL values.
Once such an order is defined, not only ⍋ but also other operators can
be generalized to use it instead of
throwing a DOMAIN ERROR.
I believe currently two APL values compare according to the following
rules (in that order):
1. Rank: higher rank > lower rank (regardless of shape or content)
2. Shape vector: bigger shape > smaller shape (regardless of content)
3. Content: characters (Unicode) < numbers (numeric value) < nested values
I understand that the sorting of character vectors looks
counter-intuitive on the first view,
but if you look at the general case then it would be even more
counter-intuitive to break the
above order in the special case of two character vectors.
And the "normal" ordering of character vectors can easily be achieved by
means of ↑¨ or so.
Once the character vectors have the same length they compare as expected.
/// Jürgen
On 07/07/2014 08:25 PM, David Lamkins wrote:
Given a list of character vectors (and scalars), grade appears to
generate the permutation vector first by length then by content.
⍋'aaa' 'xx' 'y' 'bbb' 'cc'
3 5 2 1 4
This seems counterintuitive. It seems as if ⍋ treats character strings
like numbers. Is this a bug?
--
"The secret to creativity is knowing how to hide your sources."
Albert Einstein
http://soundcloud.com/davidlamkins
http://reverbnation.com/lamkins
http://reverbnation.com/lcw
http://lamkins-guitar.com/
http://lamkins.net/
http://successful-lisp.com/