You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add generic is_sorted utility function to stdlib_sorting #1166
Currently, the stdlib_sorting module provides robust O(N log N) and O(N) sorting algorithms but lacks a fundamental O(N) utility to verify array monotonicity prior to invoking computationally expensive sorting routines. This issue proposes the implementation of a pure, generic is_sorted(array, reverse) function to unblock conditional sorting workflows and data validation. The implementation will utilize fypp templating to generate highly optimized, early-exit validation loops for all module-supported intrinsic types (int8 through int64, sp/dp/qp reals, characters) and derived types (string_type, bitset). The function will return a standard logical scalar indicating whether the array satisfies a non-decreasing order, or a non-increasing order if the optional intent(in) :: reverse logical flag is asserted as .true.. Adding this feature aligns Fortran's stdlib with standard library capabilities found in C++ (std::is_sorted) and Rust, providing an essential primitive for algorithmic optimization.
Activity