/// Returns a cloned vector of item references in sorted order. The items owned by this Array
/// retain their original order.
Returns a cloned vector of item references in sorted order. The items owned by this Array
retain their original order.
Returns a cloned vector of item references in sorted order . The items owned by this Array retain their original order .
fn sort_items(&self, options: &FormatOptions) -> Vec<Rc<RefCell<Value>>> {
        let mut items = self.items.clone();
        if options.sort_array_items {
            items.sort_by(|left, right| {
                let left: &Value = &*left.borrow();
                let right: &Value = &*right.borrow();
                if let Value::Primitive(left_primitive) = left {
                    if let Value::Primitive(right_primitive) = right {
                        let mut ordering = left_primitive
                            .value_string
                            .to_lowercase()
                            .cmp(&right_primitive.value_string.to_lowercase());
                        // If two values are case-insensitively equal, compare them again with
                        // case-sensitivity to ensure consistent re-ordering.
                        if ordering == Ordering::Equal {
                            ordering =
                                left_primitive.value_string.cmp(&right_primitive.value_string);
                        }
                        ordering
                    } else {
                        Ordering::Equal
                    }
                } else {
                    Ordering::Equal
                }
            });
        }
        items
    }
fn sort_items ( & self , options : & FormatOptions ) -> Vec < Rc < RefCell < Value > > > { let mut items = self . items . clone ( ) ; if options . sort_array_items { items . sort_by ( | left , right | { let left : & Value = & * left . borrow ( ) ; let right : & Value = & * right . borrow ( ) ; if let Value :: Primitive ( left_primitive ) = left { if let Value :: Primitive ( right_primitive ) = right { let mut ordering = left_primitive . value_string . to_lowercase ( ) . cmp ( & right_primitive . value_string . to_lowercase ( ) ) ; // If two values are case-insensitively equal, compare them again with // case-sensitivity to ensure consistent re-ordering. if ordering == Ordering :: Equal { ordering = left_primitive . value_string . cmp ( & right_primitive . value_string ) ; } ordering } else { Ordering :: Equal } } else { Ordering :: Equal } } ) ; } items }
Returns a cloned vector of item references in sorted order.
Returns a cloned vector of item references in sorted order .
&self
options
&FormatOptions