aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-08-11 18:37:14 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-08-11 18:37:14 +1200
commita6162c8d0918c80d474782ba415836bdc185e538 (patch)
tree689611f1e9d1428380f66f17eb4de7bdfb08767d
parentApply sorts to keep output stable (diff)
downloadcheckem-a6162c8d0918c80d474782ba415836bdc185e538.tar.gz (sig)
checkem-a6162c8d0918c80d474782ba415836bdc185e538.zip
Sort duplicate blocks by filesize ascendingv2.11
-rwxr-xr-xcheckem14
1 files changed, 9 insertions, 5 deletions
diff --git a/checkem b/checkem
index 78386bb..c9fdc32 100755
--- a/checkem
+++ b/checkem
@@ -25,7 +25,7 @@ use File::Find;
use Digest;
# Version number to make Perl::Critic happy
-our $VERSION = 2.10;
+our $VERSION = 2.11;
# If no arguments, work with the current working directory
if ( !@ARGV ) {
@@ -119,8 +119,12 @@ for my $fs ( grep { @{$_} > 1 } values %sizes ) {
}
# Print the groups of matched files (more than one share a checksum in the
-# final table); apply gratuitous sorts, just so the output remains the same for
-# identical file sets
-for my $dig ( sort grep { @{ $sums{$_} } > 1 } keys %sums ) {
- printf "%s\n\n", join "\n", sort map { $_->{name} } @{ $sums{$dig} };
+# final table); sort the blocks by the filesize, and the files within each
+# block by name
+for my $group (
+ sort { $a->[0]{size} <=> $b->[0]{size} }
+ grep { @{$_} > 1 } values %sums
+ )
+{
+ printf "%s\n\n", join "\n", sort map { $_->{name} } @{$group};
}