11#:include "common.fypp"
2+ #:set IRS_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES + STRING_KINDS_TYPES
23
34!! Licensing:
45!!
@@ -326,11 +327,11 @@ module stdlib_sorting
326327
327328 public char_sort_index
328329
329- public string_ord_sort
330+ public string_type_ord_sort
330331
331- public string_sort
332+ public string_type_sort
332333
333- public string_sort_index
334+ public string_type_sort_index
334335
335336 interface ord_sort
336337!! Version: experimental
@@ -346,29 +347,18 @@ module stdlib_sorting
346347!! sorted data, having O(N) performance on uniformly non-increasing or
347348!! non-decreasing data.
348349
349- #:for k1 in INT_KINDS
350+ #:for k1, t1 in IRS_KINDS_TYPES
350351 module subroutine ${k1}$_ord_sort( array, work )
351352!! Version: experimental
352353!!
353- !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `INTEGER(${k1}$) `
354+ !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `${t1}$ `
354355!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
355- integer(${k1}$) , intent(inout) :: array(0:)
356- integer(${k1}$) , intent(inout), optional :: work(0:)
356+ ${t1}$ , intent(inout) :: array(0:)
357+ ${t1}$ , intent(inout), optional :: work(0:)
357358 end subroutine ${k1}$_ord_sort
358359
359360#:endfor
360361
361- #:for k1 in REAL_KINDS
362- module subroutine ${k1}$_ord_sort( array, work )
363- !! Version: experimental
364- !!
365- !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `REAL(${k1}$)`
366- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
367- real(${k1}$), intent(inout) :: array(0:)
368- real(${k1}$), intent(inout), optional :: work(0:)
369- end subroutine ${k1}$_ord_sort
370-
371- #:endfor
372362 module subroutine char_ord_sort( array, work )
373363!! Version: experimental
374364!!
@@ -378,15 +368,6 @@ module stdlib_sorting
378368 character(len=len(array)), intent(inout), optional :: work(0:)
379369 end subroutine char_ord_sort
380370
381- module subroutine string_ord_sort( array, work )
382- !! Version: experimental
383- !!
384- !! `char_ord_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
385- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
386- type(string_type), intent(inout) :: array(0:)
387- type(string_type), intent(inout), optional :: work(0:)
388- end subroutine string_ord_sort
389-
390371 end interface ord_sort
391372
392373 interface sort
@@ -395,30 +376,16 @@ module stdlib_sorting
395376!! The generic subroutine interface implementing the `SORT` algorithm, based
396377!! on the `introsort` of David Musser.
397378
398- #:for k1 in INT_KINDS
399- pure module subroutine ${k1}$_sort( array )
400- !! Version: experimental
401- !!
402- !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `INTEGER(${k1}$)`
403- !! using a hybrid sort based on the `introsort` of David Musser.
404- !! The algorithm is of order O(N Ln(N)) for all inputs.
405- !! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
406- !! behavior is small for random data compared to other sorting algorithms.
407- integer(${k1}$), intent(inout) :: array(0:)
408- end subroutine ${k1}$_sort
409-
410- #:endfor
411-
412- #:for k1 in REAL_KINDS
379+ #:for k1, t1 in IRS_KINDS_TYPES
413380 pure module subroutine ${k1}$_sort( array )
414381!! Version: experimental
415382!!
416- !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `REAL(${k1}$) `
383+ !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `${t1}$ `
417384!! using a hybrid sort based on the `introsort` of David Musser.
418385!! The algorithm is of order O(N Ln(N)) for all inputs.
419386!! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
420387!! behavior is small for random data compared to other sorting algorithms.
421- real(${k1}$) , intent(inout) :: array(0:)
388+ ${t1}$ , intent(inout) :: array(0:)
422389 end subroutine ${k1}$_sort
423390
424391#:endfor
@@ -434,17 +401,6 @@ module stdlib_sorting
434401 character(len=*), intent(inout) :: array(0:)
435402 end subroutine char_sort
436403
437- pure module subroutine string_sort( array )
438- !! Version: experimental
439- !!
440- !! `string_sort( array )` sorts the input `ARRAY` of type `STRING_TYPE`
441- !! using a hybrid sort based on the `introsort` of David Musser.
442- !! The algorithm is of order O(N Ln(N)) for all inputs.
443- !! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
444- !! behavior is small for random data compared to other sorting algorithms.
445- type(string_type), intent(inout) :: array(0:)
446- end subroutine string_sort
447-
448404 end interface sort
449405
450406 interface sort_index
@@ -458,41 +414,24 @@ module stdlib_sorting
458414!! non-decreasing sort, but if the optional argument `REVERSE` is present
459415!! with a value of `.TRUE.` the indices correspond to a non-increasing sort.
460416
461- #:for k1 in INT_KINDS
417+ #:for k1, t1 in IRS_KINDS_TYPES
462418 module subroutine ${k1}$_sort_index( array, index, work, iwork, &
463419 reverse )
464420!! Version: experimental
465421!!
466- !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `INTEGER(${k1}$) `
422+ !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `${t1}$ `
467423!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
468424!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
469425!! order that would sort the input `ARRAY` in the desired direction.
470- integer(${k1}$) , intent(inout) :: array(0:)
426+ ${t1}$ , intent(inout) :: array(0:)
471427 integer(int_size), intent(inout) :: index(0:)
472- integer(${k1}$) , intent(inout), optional :: work(0:)
428+ ${t1}$ , intent(inout), optional :: work(0:)
473429 integer(int_size), intent(inout), optional :: iwork(0:)
474430 logical, intent(in), optional :: reverse
475431 end subroutine ${k1}$_sort_index
476432
477433#:endfor
478434
479- #:for k1 in REAL_KINDS
480- module subroutine ${k1}$_sort_index( array, index, work, iwork, &
481- reverse )
482- !! Version: experimental
483- !!
484- !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `REAL(${k1}$)`
485- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
486- !! and returns the sorted `ARRAY` and an array `INDEX of indices in the
487- !! order that would sort the input `ARRAY` in the desired direction.
488- real(${k1}$), intent(inout) :: array(0:)
489- integer(int_size), intent(inout) :: index(0:)
490- real(${k1}$), intent(inout), optional :: work(0:)
491- integer(int_size), intent(inout), optional :: iwork(0:)
492- logical, intent(in), optional :: reverse
493- end subroutine ${k1}$_sort_index
494-
495- #:endfor
496435 module subroutine char_sort_index( array, index, work, iwork, &
497436 reverse )
498437!! Version: experimental
@@ -508,21 +447,6 @@ module stdlib_sorting
508447 logical, intent(in), optional :: reverse
509448 end subroutine char_sort_index
510449
511- module subroutine string_sort_index( array, index, work, iwork, &
512- reverse )
513- !! Version: experimental
514- !!
515- !! `string_sort_index( array )` sorts an input `ARRAY` of type `STRING_TYPE`
516- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
517- !! and returns the sorted `ARRAY` and an array `INDEX of indices in the
518- !! order that would sort the input `ARRAY` in the desired direction.
519- type(string_type), intent(inout) :: array(0:)
520- integer(int_size), intent(inout) :: index(0:)
521- type(string_type), intent(inout), optional :: work(0:)
522- integer(int_size), intent(inout), optional :: iwork(0:)
523- logical, intent(in), optional :: reverse
524- end subroutine string_sort_index
525-
526450 end interface sort_index
527451
528452
0 commit comments