pub fn sort_line_range(&mut self, range: Range<usize>) {
        let l = self.line();
        let nl: usize;
        let mut buf = String::new();
        {
            let mut vec = Vec::new();
            for l in 0..self.line_count() {
                vec.push((l, self.line_buffer(l).unwrap()));
            }
            vec[range].sort_by_key(|&(_, v)| v);
            nl = vec.iter().position(|&(i, _)| i == l).unwrap();
            for (_, s) in vec.into_iter() {
                let s: String = s.iter().collect();
                buf += &s;
                buf += "\n";
            }
        }
        let c = self.column();
        self.core.reset(&buf, nl, c);
    }
/// Sort lines in a range.
///
/// # Examples
///
/// ```
/// # use edit::editor::Editor;
/// let mut editor = Editor::new("a a\n\
///                               c c\n\
///                               b b b\n\
///                               b a", 0, 3).unwrap();
/// editor.sort_line_range(0..2);
///
/// assert_eq!(editor.buffer_as_str(),
///     "a a\n\
///      c c\n\
///      b b b\n\
///      b a\n"
/// );
/// assert_eq!(editor.line(), 0);
/// assert_eq!(editor.column(), 3);
/// ```
Sort lines in a range.
Sort lines in a range .
pub fn sort_line_range(&mut self, range: Range<usize>) {
        let l = self.line();
        let nl: usize;
        let mut buf = String::new();
        {
            let mut vec = Vec::new();
            for l in 0..self.line_count() {
                vec.push((l, self.line_buffer(l).unwrap()));
            }
            vec[range].sort_by_key(|&(_, v)| v);
            nl = vec.iter().position(|&(i, _)| i == l).unwrap();
            for (_, s) in vec.into_iter() {
                let s: String = s.iter().collect();
                buf += &s;
                buf += "\n";
            }
        }
        let c = self.column();
        self.core.reset(&buf, nl, c);
    }
pub fn sort_line_range ( & mut self , range : Range < usize > ) { let l = self . line ( ) ; let nl : usize ; let mut buf = String :: new ( ) ; { let mut vec = Vec :: new ( ) ; for l in 0 .. self . line_count ( ) { vec . push ( ( l , self . line_buffer ( l ) . unwrap ( ) ) ) ; } vec [ range ] . sort_by_key ( | & ( _ , v ) | v ) ; nl = vec . iter ( ) . position ( | & ( i , _ ) | i == l ) . unwrap ( ) ; for ( _ , s ) in vec . into_iter ( ) { let s : String = s . iter ( ) . collect ( ) ; buf += & s ; buf += " \n " ; } } let c = self . column ( ) ; self . core . reset ( & buf , nl , c ) ; }
Sort lines in a range.
Sort lines in a range .
&mut self
range
Range<usize>
&mut self
range
Range<usize>
examples
None
use edit::editor::editor;
let mut editor = Editor::new("a a\n\
c c\n\
b b b\n\
b a", 0, 3).unwrap();
editor.sort_line_range(0..2).


let mut editor = Editor :: new ( " a a \ n \ c c \ n \ b b b \ n \ b a " 0 3 ) . unwrap () ; editor . sort_line_range ( 0 .. 2 ) .