Fix sorting in l command.

This commit is contained in:
Oleksandr Kozachuk
2022-12-12 12:34:26 +01:00
parent ac01307421
commit 15bb09822a
+7 -2
View File
@@ -75,9 +75,14 @@ impl<'a> LKEval<'a> {
} }
fn cmd_ls(&mut self, out: &mut Vec<String>) { fn cmd_ls(&mut self, out: &mut Vec<String>) {
let mut counter = 0; let mut tmp: Vec<String> = vec![];
for (_, name) in &self.state.borrow().db { for (_, name) in &self.state.borrow().db {
out.push(format!("{:>2} {}", Radix::new(counter, 36).unwrap().to_string(), name.borrow().to_string())); tmp.push(name.borrow().to_string());
}
tmp.sort();
let mut counter = 0;
for line in tmp {
out.push(format!("{:>3} {}", Radix::new(counter, 36).unwrap().to_string(), line));
counter += 1; counter += 1;
} }
} }