fork download
  1. indata = [
  2. "001YAMADA 080A",
  3. "015TANAKA 065B",
  4. "010YAMAMOTO 090A",
  5. "004UETA 070B"
  6. ]
  7. s = "16,1,A,13,3,D"
  8.  
  9. p indata.sort {|a, b|
  10. s.split(',').each_slice(3).inject {|c, k|
  11. i, l, d = k[0].to_i, k[1].to_i, k[2] == 'A' ? 1 : -1
  12. c = (a[i, l] <=> b[i, l]) * d
  13. break c if c.nonzero?
  14. 0
  15. }
  16. }
  17.  
Success #stdin #stdout 0.02s 7412KB
stdin
Standard input is empty
stdout
["010YAMAMOTO  090A", "001YAMADA    080A", "004UETA      070B", "015TANAKA    065B"]