assocListFromTriples xs =
  let groups = groupBy (\(a,_,_) -> \(d,_,_) -> a == d) $
               sortBy (\(a,_,_) -> \(d,_,_) -> compare a d) xs
      tripleFst (a,_,_) = a
  in map (\group -> (tripleFst $ head group, group)) groups
assocListFromTriples xs =
  let groups = groupBy (\(a,_,_) -> \(d,_,_) -> a == d) $
               sortBy (\(a,_,_) -> \(d,_,_) -> compare a d) xs
      tripleFst (a,_,_) = a
  in map (\group -> (tripleFst $ head group, group)) groups
assocListFromTriples xs =
  let groups = groupBy (\(a,_,_) -> \(d,_,_) -> a == d) $
               sortBy (\(a,_,_) -> \(d,_,_) -> compare a d) xs
      tripleFst (a,_,_) = a
  in map (\group -> (tripleFst $ head group, group)) groups