Sorting algorithms/Bubble sort: Difference between revisions

added Fortran
(added Fortran)
Line 311:
test tcnt bubble
test tcnt cells dump
 
=={{header|Fortran}}==
 
SUBROUTINE Bubble_Sort(a)
REAL, INTENT(in out), DIMENSION(:) :: a
REAL :: start, finish, temp
INTEGER :: i, last
LOGICAL :: swapped = .TRUE.
last = SIZE(a)
DO WHILE (swapped .OR. last == 1)
last = last -1
swapped = .FALSE.
DO i = 1, last
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
END DO
END SUBROUTINE Bubble_Sort
 
=={{header|Haskell}}==
179

edits