Đây là nội dung tệp của tôi.cách sắp xếp tệp trong ruby
Receivables=Por cobrar
Payables=Cuentos por pagar
ytdPurchases.label=Purchases YTD
validationError.maxValue=Value is too large, maximum value allowed is {0}
tôi muốn sắp xếp nội dung này theo thứ tự chữ cái ... Tôi có thể làm như thế nào ??
Cập nhật: Mã này sẽ sắp xếp tệp của tôi.
new_array = File.readlines("#{$base_properties}").sort
File.open("#{$base_properties}","w") do |file|
new_array.each {|n| file.puts(n)}
end
Có cách nào tốt hơn để sắp xếp tệp không?
Giải thích những gì bạn có ý nghĩa bởi _better_ – ezpz