pub struct SortOptions {
pub descending: bool,
pub nulls_first: bool,
}
Expand description
Options that define the sort order of a given column
The default sorts equivalently to of ASC NULLS FIRST
in SQL (i.e.
ascending order with nulls sorting before any other values).
§Example creation
// configure using explicit initialization
let options = SortOptions {
descending: false,
nulls_first: true,
};
// Default is ASC NULLs First
assert_eq!(options, SortOptions::default());
assert_eq!(options.to_string(), "ASC NULLS FIRST");
// Configure using builder APIs
let options = SortOptions::default()
.desc()
.nulls_first();
assert_eq!(options.to_string(), "DESC NULLS FIRST");
// configure using explicit field values
let options = SortOptions::default()
.with_descending(false)
.with_nulls_first(false);
assert_eq!(options.to_string(), "ASC NULLS LAST");
§Example operations
It is also possible to negate the sort options using the !
operator.
use arrow_schema::SortOptions;
let options = !SortOptions::default();
assert_eq!(options.to_string(), "DESC NULLS LAST");
Fields§
§descending: bool
Whether to sort in descending order
nulls_first: bool
Whether to sort nulls first
Implementations§
Source§impl SortOptions
impl SortOptions
Sourcepub fn new(descending: bool, nulls_first: bool) -> SortOptions
pub fn new(descending: bool, nulls_first: bool) -> SortOptions
Create a new SortOptions
struct
Sourcepub fn desc(self) -> SortOptions
pub fn desc(self) -> SortOptions
Set this sort options to sort in descending order
See Self::with_descending to explicitly set the underlying field
Sourcepub fn asc(self) -> SortOptions
pub fn asc(self) -> SortOptions
Set this sort options to sort in ascending order
See Self::with_descending to explicitly set the underlying field
Sourcepub fn nulls_first(self) -> SortOptions
pub fn nulls_first(self) -> SortOptions
Set this sort options to sort nulls first
See Self::with_nulls_first to explicitly set the underlying field
Sourcepub fn nulls_last(self) -> SortOptions
pub fn nulls_last(self) -> SortOptions
Set this sort options to sort nulls last
See Self::with_nulls_first to explicitly set the underlying field
Sourcepub fn with_descending(self, descending: bool) -> SortOptions
pub fn with_descending(self, descending: bool) -> SortOptions
Set this sort options to sort descending if argument is true
Sourcepub fn with_nulls_first(self, nulls_first: bool) -> SortOptions
pub fn with_nulls_first(self, nulls_first: bool) -> SortOptions
Set this sort options to sort nulls first if argument is true
Trait Implementations§
Source§impl Clone for SortOptions
impl Clone for SortOptions
Source§fn clone(&self) -> SortOptions
fn clone(&self) -> SortOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SortOptions
impl Debug for SortOptions
Source§impl Default for SortOptions
impl Default for SortOptions
Source§fn default() -> SortOptions
fn default() -> SortOptions
Source§impl Display for SortOptions
impl Display for SortOptions
Source§impl Hash for SortOptions
impl Hash for SortOptions
Source§impl Not for SortOptions
impl Not for SortOptions
!
operator is overloaded for SortOptions
to invert boolean
fields of the struct.
Source§type Output = SortOptions
type Output = SortOptions
!
operator.Source§fn not(self) -> SortOptions
fn not(self) -> SortOptions
!
operation. Read moreSource§impl Ord for SortOptions
impl Ord for SortOptions
Source§fn cmp(&self, other: &SortOptions) -> Ordering
fn cmp(&self, other: &SortOptions) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SortOptions
impl PartialEq for SortOptions
Source§impl PartialOrd for SortOptions
impl PartialOrd for SortOptions
impl Copy for SortOptions
impl Eq for SortOptions
impl StructuralPartialEq for SortOptions
Auto Trait Implementations§
impl Freeze for SortOptions
impl RefUnwindSafe for SortOptions
impl Send for SortOptions
impl Sync for SortOptions
impl Unpin for SortOptions
impl UnwindSafe for SortOptions
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.