按时间对哈希数组进行排序的最佳方法是什么?
[
{:scenario_name=>"Scenario: Two different numbers", :scenario_line=>5, :feature_file=>"multiplication.feature", :time=>"0m2.004s"},
{:scenario_name=>"Scenario: Sum of many numbers", :scenario_line=>6, :feature_file=>"addition.feature", :time=>"0m22.031s"},
{:scenario_name=>"Scenario: Regular numbers", :scenario_line=>5, :feature_file=>"division.feature", :time=>"0m3.004s"},
{:scenario_name=>"Scenario: Subtract two different numbers", :scenario_line=>6, :feature_file=>"subtraction.feature", :time=>"0m3.004s"}
]
所以,我希望它按时间(按降序)排序,例如:
[
{:scenario_name=>"Scenario: Sum of many numbers", :scenario_line=>6, :feature_file=>"addition.feature", **:time=>"0m22.031s**"},
{:scenario_name=>"Scenario: Regular numbers", :scenario_line=>5, :feature_file=>"division.feature", **:time=>"0m3.004s**"},
{:scenario_name=>"Scenario: Subtract two different numbers", :scenario_line=>6, :feature_file=>"subtraction.feature", **:time=>"0m3.004s**"},
{:scenario_name=>"Scenario: Two different numbers", :scenario_line=>5, :feature_file=>"multiplication.feature", **:time=>"0m2.004s**"}
]
时间是String
s,所以我需要将它转换为Int
之前吗?或者有什么办法可以排序?