pub struct SortByFn;Trait Implementations§
Source§impl Function for SortByFn
Sorts an array based on one or more aligned sort-by arrays.
impl Function for SortByFn
Sorts an array based on one or more aligned sort-by arrays.
SORTBY separates what is returned (array) from what determines ordering (by_array).
§Remarks
- Requires at least one
by_arrayaligned to the row count ofarray. sort_orderdefaults to ascending when omitted.- Additional
by_array/sort_ordercriteria are processed left-to-right. - Shape mismatches or invalid criteria return
#VALUE!. - Returns a spilled sorted array.
§Examples
title: "Sort names by score"
grid:
A1: "Charlie"
A2: "Alice"
A3: "Bob"
B1: 3
B2: 1
B3: 2
formula: '=SORTBY(A1:A3,B1:B3)'
expected: [["Alice"],["Bob"],["Charlie"]]title: "Sort descending by key"
grid:
A1: "Q1"
A2: "Q2"
A3: "Q3"
B1: 100
B2: 300
B3: 200
formula: '=SORTBY(A1:A3,B1:B3,-1)'
expected: [["Q2"],["Q3"],["Q1"]]related:
- SORT
- UNIQUE
- FILTER
faq:
- q: "How are multiple sort criteria applied?"
a: "SORTBY evaluates criteria left-to-right, using later by_array values only when earlier criteria compare equal."
- q: "Why do I get #VALUE! with SORTBY?"
a: "Each by_array must be one-dimensional and aligned to the primary array row count; mismatched shapes return #VALUE!."[formualizer-docgen:schema:start] Name: SORTBY Type: SortByFn Min args: 2 Max args: variadic Variadic: true Signature: SORTBY(arg1: range@range, arg2: range@range, arg3?…: number@scalar) Arg schema: arg1{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg2{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg3{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true} Caps: PURE [formualizer-docgen:schema:end]
fn name(&self) -> &'static str
fn min_args(&self) -> usize
fn variadic(&self) -> bool
fn arg_schema(&self) -> &'static [ArgSchema]
Source§fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
The unified evaluation path. Read more
fn namespace(&self) -> &'static str
fn volatile(&self) -> bool
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
Optional list of additional alias names (case-insensitive) that should resolve to this
function. Default: empty slice. Implementors can override to expose legacy names.
Returned slice must have ’static lifetime (typically a static array reference).
fn function_salt(&self) -> u64
Source§fn eval_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, _args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Option<Result<ReferenceType, ExcelError>>
Optional reference result path. Only called by the interpreter/engine
when the callsite expects a reference (e.g., range combinators, by-ref
argument positions, or spill sources). Read more
Source§fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Dispatch to the unified evaluation path with automatic argument validation.
Auto Trait Implementations§
impl Freeze for SortByFn
impl RefUnwindSafe for SortByFn
impl Send for SortByFn
impl Sync for SortByFn
impl Unpin for SortByFn
impl UnsafeUnpin for SortByFn
impl UnwindSafe for SortByFn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more