Skip to content

Instantly share code, notes, and snippets.

@crclark96
Created August 4, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crclark96/65ebf3e533351ba4929f65b4648793c9 to your computer and use it in GitHub Desktop.
Save crclark96/65ebf3e533351ba4929f65b4648793c9 to your computer and use it in GitHub Desktop.
import Data.List
import Data.Ord
charNumSort :: [String] -> [String]
charNumSort = sortBy ((comparing $ length . nub) `mappend` (comparing $ Down . length))
*Main> charNumSort ["Bananas","do","not","grow","in","Mississippi"]
["do","in","not","Mississippi","Bananas","grow"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment