How can I sort an array so that certain file extensions sort to the top?
- by rarbox
I have an array containing a list of files. I want to sort it in a way that it will let me have .txt files in the beginning of the array and the rest of files after that.
This is what I'm doing now, which works fine.
@files = (grep(/\.txt$/,@files),grep(!/\.txt$/,@files));
Is there a better way to do it though?