I just remembered I read about sorting networks here:
There was also this article from the DeepMind team (hotly debated on HackerNews),
where they managed to get rid of one instruction in a sorting network, and provided a patch for this to libc++. It’s relatively easy to use the C++ sort in Fortran, as shown here (with the downside it is linked and not instantiated in-place, e.g. for constant arrays).