alamb commented on code in PR #6441:
URL: https://github.com/apache/arrow-rs/pull/6441#discussion_r1773677323


##########
arrow-schema/src/lib.rs:
##########
@@ -42,6 +73,56 @@ pub struct SortOptions {
     pub nulls_first: bool,
 }
 
+impl Display for SortOptions {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        if self.descending {
+            write!(f, "DESC")?;
+        } else {
+            write!(f, "ASC")?;
+        }
+        if self.nulls_first {
+            write!(f, " NULLS FIRST")?;
+        } else {
+            write!(f, " NULLS LAST")?;
+        }
+        Ok(())
+    }
+}
+
+impl SortOptions {
+    /// Create a new `SortOptions` struct
+    pub fn new(descending: bool, nulls_first: bool) -> Self {
+        Self {
+            descending,
+            nulls_first,
+        }
+    }
+
+    /// Set this sort options to sort in descending order
+    pub fn desc(mut self) -> Self {
+        self.descending = true;
+        self
+    }
+
+    /// Set this sort options to sort in ascending order
+    pub fn asc(mut self) -> Self {
+        self.descending = false;
+        self
+    }
+
+    /// Set this sort options to sort descending if argument is true
+    pub fn with_descending(mut self, descending: bool) -> Self {
+        self.descending = descending;
+        self
+    }
+
+    /// Set this sort options to sort nulls first if argument is true
+    pub fn with_nulls_first(mut self, nulls_first: bool) -> Self {

Review Comment:
   it is a good idea -- I will add it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to