Skip to content

Commit d49178a

Browse files
0382jvdp1
andauthored
Apply suggestions from code review
Co-authored-by: Jeremie Vandenplas <[email protected]>
1 parent a4c8037 commit d49178a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

example/sorting/example_radix_sort.f90

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ program example_radix_sort
44
implicit none
55
integer(int8), allocatable :: arri8(:)
66
integer(int16), allocatable :: arri16(:)
7-
real(dp), allocatable, target :: arrf64(:), x
7+
real(dp) :: x
8+
real(dp), allocatable :: arrf64(:)
89

910
arri8 = [-128, 127, 0, -1, 1]
1011
call radix_sort(arri8)
@@ -19,7 +20,7 @@ program example_radix_sort
1920
arrf64 = [1.0_dp/x, 0.0_dp, 0.0_dp/x, -1.0_dp/x, -0.0_dp, 1.0_dp, -1.0_dp, 3.45_dp, -3.14_dp, 3.44_dp]
2021
call radix_sort(arrf64)
2122
print *, arrf64
22-
! In my computer, it gives
23+
! Expect output:
2324
! nan, -inf, -3.14, -1.0, -0.0, 0.0, 1.0, 3.44, 3.45, inf
24-
! but the position of nan is undefined, the position of `±inf`, `±0.0` is as expected
25+
! Note: the position of nan is undefined
2526
end program example_radix_sort

src/stdlib_sorting_radix_sort.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ pure module subroutine int16_radix_sort(array, work, reverse)
235235
end if
236236
call radix_sort_u16_helper(N, array, buffer)
237237
! After calling `radix_sort_u<width>_helper. The array is sorted as unsigned integers.
238-
! In the view of signed arrsy, the negative numbers are sorted but in the tail of the array.
239-
! Use binary search to find the boundary, and move then to correct position.
238+
! In the view of signed array, the negative numbers are sorted but in the tail of the array.
239+
! Use binary search to find the boundary, and move them to correct position.
240240
if (array(1) >= 0 .and. array(N) < 0) then
241241
start = 1
242242
end = N

0 commit comments

Comments
 (0)