I'm using eachFile(), but I'm trying to reverse the order that the iteration happens. How do I do that? Right now, it appears to sort the list of files and then process each one in sorted order. I essentially want to reserve-sort that list and start from the end.
I believe you can't alter the order of eachFile()
, but you can achieve the desired effect.
Consider:
new File("desired dir").listFiles().sort{ it.name }.reverse().each { def f ->
println f.name
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With