diff --git a/codex.cabal b/codex.cabal
--- a/codex.cabal
+++ b/codex.cabal
@@ -1,5 +1,5 @@
 name:                codex
-version:             0.3.0.4
+version:             0.3.0.6
 synopsis:            A ctags file generator for cabal project dependencies.
 description:
   This tool download and cache the source code of packages in your local hackage,
@@ -36,7 +36,7 @@
     , cryptohash          >= 0.11       && < 0.12
     , containers          >= 0.5.0.0    && < 0.6
     , directory           >= 1.2.0.1    && < 1.3
-    , either              >= 4.3.0.1    && < 4.4
+    , either              >= 4.3.0.1    && < 4.5
     , filepath            >= 1.3.0.1    && < 1.5
     , hackage-db          >= 1.22       && < 2
     , http-client         >= 0.4        && < 0.5
@@ -76,7 +76,7 @@
     , network             >= 2.6        && < 2.7
     , wreq
     , yaml                
-    , codex               == 0.3.0.4
+    , codex               == 0.3.0.6
 
 source-repository head
   type:     git
diff --git a/src/Codex.hs b/src/Codex.hs
--- a/src/Codex.hs
+++ b/src/Codex.hs
@@ -29,6 +29,7 @@
 import qualified Data.ByteString.Char8 as C8
 import qualified Data.ByteString.Lazy as BS
 import qualified Data.List as List
+import qualified Data.Set as Set
 import qualified Data.Text as Text
 import qualified Data.Text.Lazy as TextL
 import qualified Data.Text.Lazy.IO as TLIO
@@ -161,7 +162,7 @@
     mergeTags files' o' = do
       contents <- traverse TLIO.readFile files'
       let xs = concat $ fmap TextL.lines contents
-      let ys = if sorted then List.sort xs else xs
+      let ys = if sorted then (Set.toList . Set.fromList) xs else xs
       TLIO.writeFile o' $ TextL.unlines (concat [headers, ys])
     tags' = packageTags cx
     headers = if tagsFileHeader cx then fmap TextL.pack [headerFormat, headerSorted, headerHash] else []
