(j3.2006) an intrinsic for SORT()

Robert Corbett rpcorbett
Mon Feb 5 18:35:57 EST 2018


APL has a sort operator.  It also has a "grade" operator, which returns an ordinal vector for the input vector.

Most of the uses of sorting I see sort records based on key values within those records.  C's qsort function can do such sorts.  The biggest drawback of C's qsort is the overhead of calling the comparison function.  Also, qsort is not a stable sort.

Bob Corbett


> On Feb 5, 2018, at 2:47 PM, Bill Long <longb at cray.com> wrote:
> 
> 
>> On Feb 5, 2018, at 3:48 PM, Steve Lionel <steve at stevelionel.com> wrote:
>> 
>> I could see the value in a proposal for a "quicksort" intrinsic that operated on intrinsic data types and rank-1 arrays only. 
> 
> Except that ?quicksort? is misnamed. OK, it?s better than Bubble sort.  But for sorting a long list of integers (representing, for example, genomic data), radix sort is often faster.  And it scales linearly both with the length of the list  and (inversely)  with the number of images.  At least in the versions I?m familiar with, the sorting part is mostly masked by the time it takes to read in the data.  You write the two operations intertwined to hide the cross-image  communication time. Or, alternatively, hide the READ time. 
> 
> We could easily add a crummy, non-performant quicksort and warn people it is only for convenience.  But that does not seem within our normal domain.  You can find a library routine that would do that. 
> 
> Cheers,
> Bill
> 
> Bill Long                                                                       longb at cray.com
> Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
> Bioinformatics Software Development                      fax:  651-605-9143
> Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list