sort based on modified time. Thanks
add opt sort-files-mtime
What is the use case for this? When would you want to sort the files that ack searches by mtime? Or is this something that you'd only use with -f and getting a list of files, so you want to see all the files of a certain type with the most recently touched ones first?
well, just sometimes I want to see the most recent changed files with ack results. is there any other way to archive it?
When you say "ack results", are you talking about actual search results, or just using -f for a list of filenames?
When is a case that you want to see most recent first, and why?
I'm just trying to get my head around the problem that you're trying to solve. Your patch might be the way to do it, and it might not.
"ack results" is actual search results, not using -f for the list of filenames.
but yes, you're right. -f is also working.
my usage is basically very simple and it might be OK that we can do it with -f and combine with other linux command.
for example, I'm searching 'story=' in my git repos and I want to know which file is the most recent, that I can copy it as a template for another new file.
so something like
ack -f 'story=' . | other_linux_command_sort_files_on_mtime_should_also_work
But as I understand the patch, it's not going to actually sort all the files in mtime order. It's going to sort the files in each directory in mtime order, and it's going to sort the directories that it goes through in mtime order. If you have a tree of 1000 files, it's not going to sort all 1000 files. It's only going to sort per directory.
I admit that I didn't think about subdirectories.
but yes, you're correct. it's not right. it needs more fixes. I'll check it and fix it tomorrow since it's a bit later today.