diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2016-2017, Chris Dornan
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Iris Connect nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/sort.cabal b/sort.cabal
new file mode 100644
--- /dev/null
+++ b/sort.cabal
@@ -0,0 +1,39 @@
+Name:                   sort
+Version:                0.0.0.1
+Synopsis:               A Haskell sorting toolkit
+Description:            A library of general-purpose sorting utilities.
+Homepage:               https://github.com/cdornan/sort
+Author:                 Chris Dornan
+License:                BSD3
+license-file:           LICENSE
+Maintainer:             Chris Dornan <chris@chrisdornan.com>
+Copyright:              Chris Dornan 2017
+Category:               Text
+Build-type:             Simple
+Stability:              Experimental
+bug-reports:            https://github.com/cdornan/sort/issues
+
+Cabal-Version:          >= 1.10
+
+Source-Repository head
+    type:               git
+    location:           https://github.com/cdornan/sort.git
+
+Source-Repository this
+    Type:               git
+    Location:           https://github.com/cdornan/sort.git
+    Tag:                0.0.0.1
+
+Library
+    Hs-Source-Dirs:     src
+
+    Exposed-Modules:    Data.Sort
+
+    Default-Language:   Haskell2010
+
+    GHC-Options:
+      -Wall
+      -fwarn-tabs
+
+    Build-depends:
+        base                 >= 4 && < 5
diff --git a/src/Data/Sort.hs b/src/Data/Sort.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/Sort.hs
@@ -0,0 +1,29 @@
+module Data.Sort
+  ( groupSort
+  , groupSortWith
+  ) where
+
+import           Data.List
+
+
+-- | sort a list of elements with a stable sort, grouping together the
+-- equal elements with the argument grouping function
+groupSort :: Ord a => (a->[a]->b) -> [a] -> [b]
+groupSort = groupSortWith compare
+
+
+-- | sort a list of elements with a stable sort, using the argument
+-- @compare@ function determine the ordering, grouping together the
+-- equal elements with the grouping function
+groupSortWith :: (a->a->Ordering) -> (a->[a]->b) -> [a] -> [b]
+groupSortWith cmp grp = aggregate . sortBy cmp
+  where
+    aggregate []    = []
+    aggregate (h:t) = grp h eqs : aggregate rst
+      where
+        (eqs,rst) = span is_le t
+
+        is_le x   = case cmp x h of
+          LT -> True
+          EQ -> True
+          GT -> False
