pub struct SortFn;Trait Implementations§
Source§impl Function for SortFn
Sorts an array by a selected row or column and returns a spilled result.
impl Function for SortFn
Sorts an array by a selected row or column and returns a spilled result.
SORT can order rows (default) or columns.
§Remarks
- Defaults:
sort_index=1,sort_order=1(ascending),by_col=FALSE. sort_indexis 1-based in the active sort axis.sort_order < 0sorts descending; otherwise ascending.- Invalid sort indexes return
#VALUE!. - Empty input returns an empty spill.
§Examples
title: "Sort rows by second column"
grid:
A1: "C"
B1: 30
A2: "A"
B2: 10
A3: "B"
B3: 20
formula: '=SORT(A1:B3,2,1,FALSE)'
expected: [["A",10],["B",20],["C",30]]title: "Sort columns by first row descending"
grid:
A1: 1
B1: 3
C1: 2
A2: "A"
B2: "C"
C2: "B"
formula: '=SORT(A1:C2,1,-1,TRUE)'
expected: [[3,2,1],["C","B","A"]]related:
- SORTBY
- TAKE
- DROP
faq:
- q: "What changes when by_col is TRUE?"
a: "SORT reorders columns instead of rows, and sort_index is interpreted as a row index used as the sort key."
- q: "What causes #VALUE! in SORT?"
a: "If sort_index is outside the active axis (row or column axis based on by_col), SORT returns #VALUE!."[formualizer-docgen:schema:start] Name: SORT Type: SortFn Min args: 1 Max args: variadic Variadic: true Signature: SORT(arg1: range@range, arg2?: number@scalar, arg3?: number@scalar, arg4?…: logical@scalar) Arg schema: arg1{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg2{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg3{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg4{kinds=logical,required=false,shape=scalar,by_ref=false,coercion=Logical,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>
fn namespace(&self) -> &'static str
fn volatile(&self) -> bool
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
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>>
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>
Auto Trait Implementations§
impl Freeze for SortFn
impl RefUnwindSafe for SortFn
impl Send for SortFn
impl Sync for SortFn
impl Unpin for SortFn
impl UnsafeUnpin for SortFn
impl UnwindSafe for SortFn
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
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>
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>
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