Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 42 lines (25 sloc) 0.532 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
output = ""
output2 = []

File.open("../input.txt") { |file|
 header = file.gets
 
 output += header
  
 while(lines = file.gets)
   fields = lines.split("\t")
   
   fields[1] = fields[1].gsub(/[^a-zA-Z]/, '').reverse
   
   if(!fields[1].empty?)
    output2 << fields
   end
   
 end
  
}


#sort

output2 = output2.sort { |x, y|

first = x[1] <=> y[1]

if first == 0
  first = x[5].to_f <=> y[5].to_f
end

 first
  
}


output2.each { |line|
output += line.join("\t")
  }

File.open("output.txt", 'w') {|f| f.write(output) }
Something went wrong with that request. Please try again.