datafort_sorting Module

DataFort Sorting Module

This module provides standalone functions for sorting and ranking operations on data frames. All functions take a data_frame as the first argument instead of being type-bound procedures.

Functions

Sorting Functions

  • df_sort_by_column(df, col_index, ascending) - Sort data frame by column values

Sorting Check Functions

  • df_is_sorted_real(df, col_index, ascending) - Check if real column is sorted
  • df_is_sorted_integer(df, col_index, ascending) - Check if integer column is sorted

Ranking Functions

  • df_rank_real(df, col_index, ascending) - Get ranks for real column values
  • df_rank_integer(df, col_index, ascending) - Get ranks for integer column values


Functions

public function df_is_sorted_integer(df, col_index, ascending) result(sorted)

Check if an integer column is sorted

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
logical, intent(in), optional :: ascending

Return Value logical

public function df_is_sorted_real(df, col_index, ascending) result(sorted)

Check if a real column is sorted

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
logical, intent(in), optional :: ascending

Return Value logical

public function df_rank_integer(df, col_index, ascending) result(ranks)

Rank values in an integer column

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
logical, intent(in), optional :: ascending

Return Value integer(kind=ik), dimension(:), allocatable

public function df_rank_real(df, col_index, ascending) result(ranks)

Rank values in a real column

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
logical, intent(in), optional :: ascending

Return Value integer(kind=ik), dimension(:), allocatable

private function partition_indices_integer(values, indices, low, high, ascending) result(pivot_idx)

Partition function for integer value quicksort

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
integer, intent(in) :: low
integer, intent(in) :: high
logical, intent(in) :: ascending

Return Value integer

private function partition_indices_real(values, indices, low, high, ascending) result(pivot_idx)

Partition function for real value quicksort

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
integer, intent(in) :: low
integer, intent(in) :: high
logical, intent(in) :: ascending

Return Value integer


Subroutines

public subroutine df_sort_by_column(df, col_index, ascending)

Sort data frame by column values

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index
logical, intent(in), optional :: ascending

private recursive subroutine quicksort_indices_integer(values, indices, low, high, ascending)

Quicksort implementation for integer value indices

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
integer, intent(in) :: low
integer, intent(in) :: high
logical, intent(in) :: ascending

private recursive subroutine quicksort_indices_real(values, indices, low, high, ascending)

Quicksort implementation for real value indices

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
integer, intent(in) :: low
integer, intent(in) :: high
logical, intent(in) :: ascending

private subroutine reorder_all_columns(df, indices)

Reorder all columns based on index array

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in), dimension(:) :: indices

private subroutine sort_indices_integer(values, indices, ascending)

Sort indices array based on integer values

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=ik), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
logical, intent(in) :: ascending

private subroutine sort_indices_real(values, indices, ascending)

Sort indices array based on real values

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: values
integer, intent(inout), dimension(:) :: indices
logical, intent(in) :: ascending