Skip to content

Commit

Permalink
Support for custom comparator code
Browse files Browse the repository at this point in the history
e.g. --order '{ a, b -> 0 }'
  • Loading branch information
rednoah committed Feb 4, 2023
1 parent c4219d1 commit c4f2b13
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions duplicates.groovy
Expand Up @@ -11,6 +11,7 @@ order = 'INPUT' .equalsIgnoreCase(_args.order) ? 'INPUT'
: 'SIZE' .equalsIgnoreCase(_args.order) ? 'SIZE'
: 'DATE' .equalsIgnoreCase(_args.order) ? 'DATE'
: 'TIME' .equalsIgnoreCase(_args.order) ? 'TIME'
: _args.order ==~ /^[{].*[}]$/ ? evaluate(_args.order) // e.g. --order '{ a, b -> 0 }'
: binary ? 'INPUT' : 'QUALITY'


Expand Down Expand Up @@ -71,6 +72,8 @@ def order(files) {
return files.toSorted{ -(it.mediaCharacteristics?.creationTime?.toEpochMilli() ?: it.creationDate) }
case 'TIME':
return files.toSorted{ -(it.lastModified()) }
default:
return files.toSorted(order)
}
}

Expand Down

0 comments on commit c4f2b13

Please sign in to comment.