| skipped 127 lines |
128 | 128 | | duplicates |
129 | 129 | | .clone() |
130 | 130 | | .into_iter() |
| 131 | + | .sorted_unstable_by_key(|f| { |
| 132 | + | -(f.1.first().and_then(|ff| ff.size).unwrap_or_default() as i64) |
| 133 | + | }) // sort by descending file size in interactive mode |
131 | 134 | | .enumerate() |
132 | 135 | | .for_each(|(gindex, (_, group))| { |
133 | 136 | | let mut itable = Table::new(); |
| skipped 25 lines |
159 | 162 | | |
160 | 163 | | let mut output_table = Table::new(); |
161 | 164 | | output_table.set_titles(row!["hash", "duplicates"]); |
162 | | - | duplicates.into_iter().for_each(|(hash, group)| { |
163 | | - | let mut inner_table = Table::new(); |
164 | | - | inner_table.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR); |
165 | | - | group.iter().for_each(|file| { |
166 | | - | inner_table.add_row(row![ |
167 | | - | format_path(&file.path, opts).unwrap_or_default().blue(), |
168 | | - | file_size(&file).unwrap_or_default().red(), |
169 | | - | modified_time(&file.path).unwrap_or_default().yellow() |
170 | | - | ]); |
| 165 | + | duplicates |
| 166 | + | .into_iter() |
| 167 | + | .sorted_unstable_by_key(|f| f.1.first().and_then(|ff| ff.size).unwrap_or_default()) // sort by ascending size |
| 168 | + | .for_each(|(hash, group)| { |
| 169 | + | let mut inner_table = Table::new(); |
| 170 | + | inner_table.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR); |
| 171 | + | group.iter().for_each(|file| { |
| 172 | + | inner_table.add_row(row![ |
| 173 | + | format_path(&file.path, opts).unwrap_or_default().blue(), |
| 174 | + | file_size(&file).unwrap_or_default().red(), |
| 175 | + | modified_time(&file.path).unwrap_or_default().yellow() |
| 176 | + | ]); |
| 177 | + | }); |
| 178 | + | output_table.add_row(row![hash.green(), inner_table]); |
171 | 179 | | }); |
172 | | - | output_table.add_row(row![hash.green(), inner_table]); |
173 | | - | }); |
174 | 180 | | |
175 | 181 | | output_table.printstd(); |
176 | 182 | | } |
| skipped 1 lines |