Skip to content

Sorting #101

@jacobwilliams

Description

@jacobwilliams

I wonder if sorting should be built into the language? This is such a fundamental thing that currently take a staggering amount of code to make it work with all intrinsic types and user-defined types (see for example here). I think C++ has sorting built in to its standard library.

Features:

  • sort ascending or descending
  • it works for all intrinsic numeric types (integer(kind=*) and real(kind=*))
  • how about also a "sort x, while carrying y along"? That's always nice to have. See, for example, isort from SLATEC. Or even a variadic "sort x while carrying any number of other arrays along". And any of them can be any combination of types.
  • maybe also indexing?
  • how about lexical sorting? Including "[natural sorting]?(https://en.wikipedia.org/wiki/Natural_sort_order)".

I think it goes without saying that any well-designed future generic/templating feature should also allow one to apply a sorting algorithm (either one from a third-party library or maybe even the hypothetical intrinsic one) to a user-defined type with a minimum of code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 16Standard Clause 16: Intrinsic procedures and modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions