Check if an integer column is sorted
Verifies whether the values in an integer column are in sorted order
@param[in] df The data frame instance @param[in] col_index Index of column to check @param[in] ascending Optional sort direction to check (default: .true.) @return .true. if column is sorted, .false. otherwise
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(in) | :: | df | |||
integer, | intent(in) | :: | col_index | |||
logical, | intent(in), | optional | :: | ascending |
function df_is_sorted_integer(df, col_index, ascending) result(sorted) type(data_frame), intent(in) :: df integer, intent(in) :: col_index logical, intent(in), optional :: ascending logical :: sorted integer(ik), dimension(:), allocatable :: col type(column) :: data_col logical :: asc integer :: i asc = .true. if (present(ascending)) asc = ascending data_col = df % get_data_col(col_index) col = data_col % geti() sorted = .true. if (asc) then do i = 1, size(col) - 1 if (col(i) > col(i + 1)) then sorted = .false. return end if end do else do i = 1, size(col) - 1 if (col(i) < col(i + 1)) then sorted = .false. return end if end do end if end function df_is_sorted_integer