Skip to content

Commit 70e13f8

Browse files
authored
Merge pull request #4 from jvdp1/sort_sign
Uupdate of the comments in source code
2 parents 933837a + 720a0cd commit 70e13f8

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

doc/specs/stdlib_sorting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ decreasing, value.
286286

287287
##### Syntax
288288

289-
`call [[stdlib_sorting(module):sort(subroutine)]]sort ( array, reverse )`
289+
`call [[stdlib_sorting(module):sort(subroutine)]]sort ( array[, reverse] )`
290290

291291
##### Class
292292

src/stdlib_sorting.fypp

+22-9
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ module stdlib_sorting
139139
!! Version: experimental
140140
!!
141141
!! The generic subroutine implementing the `ORD_SORT` algorithm to return
142-
!! an input array with its elements sorted in order of non-decreasing
142+
!! an input array with its elements sorted in order of (non-)decreasing
143143
!! value. Its use has the syntax:
144144
!!
145-
!! call ord_sort( array[, work] )
145+
!! call ord_sort( array[, work, reverse] )
146146
!!
147147
!! with the arguments:
148148
!!
@@ -161,6 +161,12 @@ module stdlib_sorting
161161
!! storage, its use can significantly reduce the stack memory requirements
162162
!! for the code. Its value on return is undefined.
163163
!!
164+
!! * `reverse` (optional): shall be a scalar of type default logical. It
165+
!! is an `intent(in)` argument. If present with a value of `.true.` then
166+
!! `array` will be sorted in order of non-increasing values in stable
167+
!! order. Otherwise index will sort `array` in order of non-decreasing
168+
!! values in stable order.
169+
!!
164170
!!#### Example
165171
!!
166172
!!```fortran
@@ -183,10 +189,10 @@ module stdlib_sorting
183189
!! Version: experimental
184190
!!
185191
!! The generic subroutine implementing the `SORT` algorithm to return
186-
!! an input array with its elements sorted in order of non-decreasing
192+
!! an input array with its elements sorted in order of (non-)decreasing
187193
!! value. Its use has the syntax:
188194
!!
189-
!! call sort( array )
195+
!! call sort( array[, reverse] )
190196
!!
191197
!! with the arguments:
192198
!!
@@ -197,6 +203,11 @@ module stdlib_sorting
197203
!! real and at least one of the elements is a `NaN`, then the ordering
198204
!! of the result is undefined. Otherwise it is defined to be the
199205
!! original elements in non-decreasing order.
206+
!! * `reverse` (optional): shall be a scalar of type default logical. It
207+
!! is an `intent(in)` argument. If present with a value of `.true.` then
208+
!! `array` will be sorted in order of non-increasing values in unstable
209+
!! order. Otherwise index will sort `array` in order of non-decreasing
210+
!! values in unstable order.
200211
!!
201212
!!#### Example
202213
!!
@@ -351,7 +362,7 @@ module stdlib_sorting
351362
module subroutine char_ord_sort( array, work, reverse )
352363
!! Version: experimental
353364
!!
354-
!! `char_ord_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
365+
!! `char_ord_sort( array[, work, reverse] )` sorts the input `ARRAY` of type `CHARACTER(*)`
355366
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
356367
character(len=*), intent(inout) :: array(0:)
357368
character(len=len(array)), intent(out), optional :: work(0:)
@@ -370,7 +381,7 @@ module stdlib_sorting
370381
pure module subroutine ${k1}$_sort( array, reverse )
371382
!! Version: experimental
372383
!!
373-
!! `${k1}$_sort( array )` sorts the input `ARRAY` of type `${t1}$`
384+
!! `${k1}$_sort( array[, reverse] )` sorts the input `ARRAY` of type `${t1}$`
374385
!! using a hybrid sort based on the `introsort` of David Musser.
375386
!! The algorithm is of order O(N Ln(N)) for all inputs.
376387
!! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
@@ -384,7 +395,7 @@ module stdlib_sorting
384395
pure module subroutine char_sort( array, reverse )
385396
!! Version: experimental
386397
!!
387-
!! `char_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
398+
!! `char_sort( array[, reverse] )` sorts the input `ARRAY` of type `CHARACTER(*)`
388399
!! using a hybrid sort based on the `introsort` of David Musser.
389400
!! The algorithm is of order O(N Ln(N)) for all inputs.
390401
!! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
@@ -411,7 +422,8 @@ module stdlib_sorting
411422
reverse )
412423
!! Version: experimental
413424
!!
414-
!! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `${t1}$`
425+
!! `${k1}$_sort_index( array, index[, work, iwork, reverse] )` sorts
426+
!! an input `ARRAY` of type `${t1}$`
415427
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
416428
!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
417429
!! order that would sort the input `ARRAY` in the desired direction.
@@ -428,7 +440,8 @@ module stdlib_sorting
428440
reverse )
429441
!! Version: experimental
430442
!!
431-
!! `char_sort_index( array )` sorts an input `ARRAY` of type `CHARACTER(*)`
443+
!! `char_sort_index( array, index[, work, iwork, reverse] )` sorts
444+
!! an input `ARRAY` of type `CHARACTER(*)`
432445
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
433446
!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
434447
!! order that would sort the input `ARRAY` in the desired direction.

src/stdlib_sorting_sort.fypp

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ contains
8787
#:for k1, t1 in IRS_KINDS_TYPES
8888

8989
pure subroutine ${k1}$_${sname}$_sort( array )
90-
! `${k1}$_sort( array )` sorts the input `ARRAY` of type `${t1}$`
90+
! `${k1}$_${sname}$_sort( array )` sorts the input `ARRAY` of type `${t1}$`
9191
! using a hybrid sort based on the `introsort` of David Musser. As with
92-
! `introsort`, `${k1}$_sort( array )` is an unstable hybrid comparison
92+
! `introsort`, `${k1}$_${sname}$_sort( array )` is an unstable hybrid comparison
9393
! algorithm using `quicksort` for the main body of the sort tree,
94-
! supplemented by `insertion sort` for the outer brances, but if
94+
! supplemented by `insertion sort` for the outer branches, but if
9595
! `quicksort` is converging too slowly the algorithm resorts
9696
! to `heapsort`. The algorithm is of order O(N Ln(N)) for all inputs.
9797
! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
@@ -275,11 +275,11 @@ contains
275275

276276
#:for sname, signt, signoppt in SIGN_NAME_TYPE
277277
pure subroutine char_${sname}$_sort( array )
278-
! `char_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
278+
! `char_${sname}$_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
279279
! using a hybrid sort based on the `introsort` of David Musser. As with
280-
! `introsort`, `char_sort( array )` is an unstable hybrid comparison
280+
! `introsort`, `char_${sname}$_sort( array )` is an unstable hybrid comparison
281281
! algorithm using `quicksort` for the main body of the sort tree,
282-
! supplemented by `insertion sort` for the outer brances, but if
282+
! supplemented by `insertion sort` for the outer branches, but if
283283
! `quicksort` is converging too slowly the algorithm resorts
284284
! to `heapsort`. The algorithm is of order O(N Ln(N)) for all inputs.
285285
! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))

0 commit comments

Comments
 (0)