s cmp (x:xs) = (s cmp $ filter lessThanX xs) ++ x : (s cmp $ filter (not . lessThanX) xs)
             where lessThanX = (\y -> (cmp y x) == LT)


-- IV) Second qst
-- s (compare `on` length) ["xjkh", "jfh", "dgj", "jihghui", "jkh", "j", "kh"]
s cmp (x:xs) = (s cmp $ filter lessThanX xs) ++ x : (s cmp $ filter (not . lessThanX) xs)
             where lessThanX = (\y -> (cmp y x) == LT)


-- IV) Second qst
-- s (compare `on` length) ["xjkh", "jfh", "dgj", "jihghui", "jkh", "j", "kh"]
s cmp (x:xs) = (s cmp $ filter lessThanX xs) ++ x : (s cmp $ filter (not . lessThanX) xs)
             where lessThanX = (\y -> (cmp y x) == LT)


-- IV) Second qst
-- s (compare `on` length) ["xjkh", "jfh", "dgj", "jihghui", "jkh", "j", "kh"]