<commit_before>module Quicksort
  ( quicksort,
    part
  ) where

quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = (quicksort (getLt parts)) ++ (x:(getEq parts)) ++ (quicksort (getGt parts))
  where
    parts = part xs x

getGt :: (a,b,c) -> a
getGt (x,_,_) = x

getEq :: (a,b,c) -> b
getEq (_,x,_) = x

getLt :: (a,b,c) -> c
getLt (_,_,x) = x

part l y = f [] [] [] l
  where
    f gt eq lt (x:xs) =
      if x > y then f (x:gt) eq lt xs
      else if x == y then f gt (x:eq) lt xs
      else f gt eq (x:lt) xs
    f gt eq lt [] = (gt, eq, lt)<commit_msg>Added comment to quicksort in haskell.<commit_after>module Quicksort
  ( quicksort,
    part
  ) where

{-
As input get list of elements that can be ordered. In output there is list sorted using quicksort alghoritm.
-}
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = (quicksort (getLt parts)) ++ (x:(getEq parts)) ++ (quicksort (getGt parts))
  where
    parts = part xs x

getGt :: (a,b,c) -> a
getGt (x,_,_) = x

getEq :: (a,b,c) -> b
getEq (_,x,_) = x

getLt :: (a,b,c) -> c
getLt (_,_,x) = x

part l y = f [] [] [] l
  where
    f gt eq lt (x:xs) =
      if x > y then f (x:gt) eq lt xs
      else if x == y then f gt (x:eq) lt xs
      else f gt eq (x:lt) xs
    f gt eq lt [] = (gt, eq, lt)
{'fraction_non_alphanumeric': 0.17824074074074073, 'fraction_numerical': 0.0, 'mean_word_length': 2.5437158469945356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5476533', 'n_tokens_mistral': 587, 'n_tokens_neox': 568, 'n_words': 197}