reorderPackets :: PcapHandle -> IO ()
reorderPackets !hdl = go maxDiff minDiff []
 where
   go !min !max !xs 
    | max - min >= diffSec = do mapM_ (putStrLn . show) $! sort xs
                                go maxDiff minDiff []
    | otherwise 
      = do (!pkt, !bs) <- nextBS hdl
           if hdrWireLength pkt == 0
              then mapM_ (putStrLn . show) $! sort xs 
              else do let !pktTime = pktToDiff pkt
                      let !(Right !q) = P.parse parseQuote bs
                      let (nMin, nMax) = newMinMax min max 
                                                  (qAcceptTime q) pktTime
                      go nMin nMax $!! (pktTime, q):xs
   newMinMax :: DiffTime -> DiffTime -> DiffTime -> DiffTime -> 
                  (DiffTime, DiffTime)
   {-# INLINE newMinMax #-}
   newMinMax !minn !maxx !qt !pt = let !mi = min minn qt
                                       !ma = max maxx pt
                                   in (mi, ma)
reorderPackets :: PcapHandle -> IO ()
reorderPackets !hdl = go maxDiff minDiff []
 where
   go !min !max !xs 
    | max - min >= diffSec = do mapM_ (putStrLn . show) $! sort xs
                                go maxDiff minDiff []
    | otherwise 
      = do (!pkt, !bs) <- nextBS hdl
           if hdrWireLength pkt == 0
              then mapM_ (putStrLn . show) $! sort xs 
              else do let !pktTime = pktToDiff pkt
                      let !(Right !q) = P.parse parseQuote bs
                      let (nMin, nMax) = newMinMax min max 
                                                  (qAcceptTime q) pktTime
                      go nMin nMax $!! (pktTime, q):xs
   newMinMax :: DiffTime -> DiffTime -> DiffTime -> DiffTime -> 
                  (DiffTime, DiffTime)
   {-# INLINE newMinMax #-}
   newMinMax !minn !maxx !qt !pt = let !mi = min minn qt
                                       !ma = max maxx pt
                                   in (mi, ma)
reorderPackets !hdl = go maxDiff minDiff []
 where
   go !min !max !xs 
    | max - min >= diffSec = do mapM_ (putStrLn . show) $! sort xs
                                go maxDiff minDiff []
    | otherwise 
      = do (!pkt, !bs) <- nextBS hdl
           if hdrWireLength pkt == 0
              then mapM_ (putStrLn . show) $! sort xs 
              else do let !pktTime = pktToDiff pkt
                      let !(Right !q) = P.parse parseQuote bs
                      let (nMin, nMax) = newMinMax min max 
                                                  (qAcceptTime q) pktTime
                      go nMin nMax $!! (pktTime, q):xs
   newMinMax :: DiffTime -> DiffTime -> DiffTime -> DiffTime -> 
                  (DiffTime, DiffTime)
   {-# INLINE newMinMax #-}
   newMinMax !minn !maxx !qt !pt = let !mi = min minn qt
                                       !ma = max maxx pt
                                   in (mi, ma)