저는이 튜플에 타임 스탬프가 포함되어 있으면 하나의 튜플 목록을 가지고 있습니다. 나는 타임 스탬프로이 목록을 주문하고 같이 매핑 변환하려고 :지도의 타임 스탬프 정렬
println(s"--list before order ${vendingMachineResults.map(v => v._5.timestamp)}")
val vendingMachineResultsGroupedByTimestamp =
vendingMachineResults.sortBy(v1 =>
(new DateTime(v1._5.timestamp)).toDate()
).flatMap(vendingMachineResult =>
Map(vendingMachineResult._5.timestamp -> vendingMachineResult)
).toMap
println(s"--Map with vending machines ordered by timestamp: ${vendingMachineResultsGroupedByTimestamp.keys}")
하지만 출력은 잘못된 것입니다 :
--List before ordering:
List(2012-04-16 14:33:34.807,
2012-02-16 14:52:25.715,
2012-06-18 14:52:25.715,
2012-07-10 14:54:19.651,
2012-07-16 14:54:19.651)
--Map with vending machines ordered by timestamp:
Set(2012-04-16 14:33:34.807,
2012-02-16 14:52:25.715,
2012-06-18 14:52:25.715,
2012-07-16 14:54:19.651,
2012-07-10 14:54:19.651)
사람이 내가 잘못하고있는 무슨 아이디어가 있습니까? 시간 소인은 오름차순으로 기대되지만 그렇지 않습니다.