File: PHeapSort.hs

package info (click to toggle)
haskell-pqueue 1.5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: haskell: 3,162; makefile: 5
file content (11 lines) | stat: -rw-r--r-- 344 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
module PHeapSort where

import Data.PQueue.Prio.Min (MinPQueue)
import qualified Data.PQueue.Prio.Min as P
import System.Random

heapSortRandoms :: Int -> StdGen -> [Int]
heapSortRandoms n gen = heapSort $ take n (randoms gen)

heapSort :: Ord a => [a] -> [a]
heapSort xs = [b | (b, ~()) <- P.toAscList . P.fromList . map (\a -> (a, ())) $ xs]