! Figure 7.6
  module sort           ! To sort postal addresses by zip code.
     public  :: selection_sort
     private :: swap
     integer, parameter, private :: string_length = 30
     type, public :: address
        character(len = string_length) :: name, street, town
        character(len=2)               :: state
        integer                        :: zip_code
     end type address
  contains
     recursive subroutine selection_sort (array_arg)
        type (address), dimension (:), intent (inout)           &
                                             :: array_arg
        integer                              :: current_size
        integer, dimension (1)               :: big
             ! Result of maxloc (Section 8.13) is array valued
        current_size = size (array_arg)
        if (current_size > 0) then
           big = maxloc (array_arg(:) % zip_code)
           call swap (array_arg(big(1)), array_arg(current_size))
           call selection_sort (array_arg(1: current_size - 1))
        end if
     end subroutine selection_sort
     subroutine swap (i, j)
        type (address), intent (inout) :: i, j
        type (address)  :: temp
        temp = i
        i = j
        j = temp
     end subroutine swap
  end module sort
