(j3.2006) an intrinsic for SORT()

Clune, Thomas L. GSFC-6101 thomas.l.clune
Mon Feb 5 17:26:08 EST 2018


> On Feb 5, 2018, at 4:48 PM, Steve Lionel <steve at stevelionel.com> wrote:
> 
> On 2/5/2018 4:39 PM, Clune, Thomas L. (GSFC-6101) wrote:
>> A colleague was pressing me on why Fortran does not include an intrinsic procedure for sorting integers and reals.   I gave him some of the likely reasons that such an intrinsic may not get much priority, but thought I?d at least ping the mailing list to gauge interest/history.   I strongly suspect the issue has come up before.   But if not, or if there are other reasons to think the situation has changed, I?d be happy to submit some use cases for this.
>> 
> There have been a lot of suggestions for something like the C++ STL for Fortran, or at least a large number of additional library routines. RANDOM_NUMBER is fairly easy to specify, but sorting various types and shapes of variables quickly gets messy. I could see the value in a proposal for a "quicksort" intrinsic that operated on intrinsic data types and rank-1 arrays only.  Sorting derived types would require some sort of type-bound compare operator to be defined.

I agree that the priority would be for something that just did numeric intrinsics in rank-1 arrays only.       _If_ a generic programming facility is added to the language, and depending on its details even then, a subsequent revision could revisit an extension of the intrinsic.

> 
> Which other languages have a sort intrinsic?

I don?t think I said that any did. :-)     But certainly C++ does, along with Python, Mathematica, ?   Apparently it is part of stdlib in C.    For both C and C++ one might be splitting hairs on what is ?in? the language as opposed to ?always? available.

> 
> Steve
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list