Skip to content

Commit

Permalink
Sorting by size, descending, for entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 3, 2019
1 parent 9720931 commit e8cb9dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ termion = "1.5.2"
atty = "0.2.11"
tui = "0.6.0"
petgraph = "0.4.13"
itertools = "0.8.0"

[[bin]]
name="dua"
Expand Down
3 changes: 3 additions & 0 deletions src/interactive/widgets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{DisplayOptions, Traversal, Tree, TreeIndex};
use crate::ByteFormat;
use itertools::Itertools;
use tui::layout::{Constraint, Direction, Layout};
use tui::style::{Color, Style};
use tui::{
Expand Down Expand Up @@ -97,6 +98,8 @@ impl<'a> Widget for Entries<'a> {
List::new(
tree.neighbors_directed(*root, Direction::Outgoing)
.filter_map(|w| tree.node_weight(w))
.sorted_by(|l, r| l.size.cmp(&r.size))
.rev()
.map(|w| {
Text::Raw(
format!(
Expand Down

0 comments on commit e8cb9dc

Please sign in to comment.