Skip to content

Instantly share code, notes, and snippets.

@moretea
Created June 15, 2011 07:46
Show Gist options
  • Select an option

  • Save moretea/1026658 to your computer and use it in GitHub Desktop.

Select an option

Save moretea/1026658 to your computer and use it in GitHub Desktop.
order_files
syslogs = [
"/path/to/log/apache.5.gz",
"/path/to/log/apache.1.gz",
"/path/to/log/apache.10.gz",
"/path/to/log/apache.256.gz"
]
output = syslogs.collect do |file_name|
file_name.match /(.*)\.(\d+)\.gz/
[$2.to_i, file_name]
end.sort_by { |decorated| decorated[0] }.collect { |decorated| decorated[1] }
p output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment