indata = [
"001YAMADA 080A",
"015TANAKA 065B",
"010YAMAMOTO 090A",
"004UETA 070B"
]
s = "16,1,A,13,3,D"
p indata.sort {|a, b|
s.split(',').each_slice(3).inject {|c, k|
i, l, d = k[0].to_i, k[1].to_i, k[2] == 'A' ? 1 : -1
c = (a[i, l] <=> b[i, l]) * d
break c if c.nonzero?
0
}
}
aW5kYXRhID0gWwoJIjAwMVlBTUFEQSAgICAwODBBIiwKCSIwMTVUQU5BS0EgICAgMDY1QiIsCgkiMDEwWUFNQU1PVE8gIDA5MEEiLAoJIjAwNFVFVEEgICAgICAwNzBCIgpdCnMgPSAiMTYsMSxBLDEzLDMsRCIKCnAgaW5kYXRhLnNvcnQge3xhLCBifAoJcy5zcGxpdCgnLCcpLmVhY2hfc2xpY2UoMykuaW5qZWN0IHt8Yywga3wKCQlpLCBsLCBkID0ga1swXS50b19pLCBrWzFdLnRvX2ksIGtbMl0gPT0gJ0EnID8gMSA6IC0xCgkJYyA9IChhW2ksIGxdIDw9PiBiW2ksIGxdKSAqIGQKCQlicmVhayBjIGlmIGMubm9uemVybz8KCQkwCgl9Cn0K