Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Bubble Sort/BubbleSort.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module sorting

contains

subroutine bubblesort(td,A,n)
integer, intent(in) :: td
integer, intent(in out), dimension(td) :: A
integer, intent(in) :: n
integer :: i, j, temp
logical :: swapped

do j = n-1, 1, -1
swapped = .false.
do i = 1, j
if (A(i) > A(i+1)) then
temp = A(i)
A(i) = A(i+1)
A(i+1) = temp
swapped = .true.
end if
end do
if (.not. swapped) exit
end do
end subroutine bubblesort

end module sorting