在Ruby我有數組的數組,看起來像這樣的一個值,以斯馬什2D陣列:紅寶石:如何基於元素
[["2011-12-03 01:21:31", "Closed", ""],
["2011-11-11 00:42:40", "", "Smith, Bob"],
["2011-11-11 00:42:40", "Escalated", ""],
["2011-11-10 21:36:11", "", "ABC Team"],
["2011-11-10 21:36:11", "Escalated", ""],
["2011-11-10 18:42:19", "", "Smith, Bob"],
["2011-11-10 18:42:19", "Escalated", ""],
["2011-11-09 22:55:01", "", "Global Design"],
["2011-11-09 22:55:01", "Escalated", ""],
["2011-09-28 18:56:32", "", "Jones, Fred"],
["2011-09-28 18:56:32", "Escalated", ""],
["2011-09-28 07:19:28", "", ""],
["2011-09-28 07:19:28", "", ""],
["2011-09-28 07:19:28", "", ""],
["2011-09-28 07:19:28", "", ""],
["2011-09-28 07:19:28", "", "Finance"],
["2011-09-28 07:19:28", "Escalated", ""]]
我想基於時間戳的條目斯馬什一起。我希望得到的陣列看起來像:
[["2011-12-03 01:21:31", "Closed", ""],
["2011-11-11 00:42:40", "Escalated", "Smith, Bob"],
["2011-11-10 21:36:11", "Escalated", "ABC Team"],
["2011-11-10 18:42:19", "Escalated", "Smith, Bob"],
["2011-11-09 22:55:01", "Escalated", "Global Design"],
["2011-09-28 18:56:32", "Escalated", "Jones, Fred"],
["2011-09-28 07:19:28", "Escalated", "Finance"]]
任何有效的方式來實現這個在Ruby中的想法?
可枚舉的GROUP_BY這裏是你的朋友。 – squiguy 2013-05-10 20:55:25
你的問題不清楚。何時清除空字符串?它看起來是任意的。什麼決定了時間戳之後的元素的順序? – sawa 2013-05-10 21:23:28