Cześć Bartku,
Frankly, I had no problems with my recursive FCMP implementation at any N, except having to use the quick sort all the way without switching to the straight insertion sort at some M => 9 point (you can find it in the SAS-L archives; or alternatively I can send it to you if you're interested).
Any purely SAS "external" array sort implementation I've tried runs about twice or more the time compared to SORTN - not surprising since it's internal, even though based on the heap sort, not quite the fastest sorting scheme. For the sake of curiosity, I've implemented the heap sort "externally" (i.e. in DATA step code using the LINK routine for heap-rebuilding recursion), and it's about 4 times slower than SORTN. However, PROTO C quick sort coupled with FCMP (Matt Kastin posted it on SAS-L circa 2017-18, IIRC) is almost on par with SORTN speed-wise (not surprising, either).
OTOH, external array-sorting routines are much more functionally flexible than SORTN/C in terms of ascending/descending, handling dupes, sorting parallel arrays, etc. All these options are the simplest to implement using the hash object, particularly when more than one array is used as the key, even though it comes at the expense of losing some speed compared to the hard-core implementations like quick sort.
Serdeczne pozdrowienia,
Pavlo
... View more