Function to sort a list of tuples - Haskell
haskell
Solution
You forgot to make your function take an argument.
results :: [a] -> [(Int, a)]
results score = sort (frequency score)
Without it, the compiler sees your type signature and infers that in order to return something of type `[a] -> [(Int, a)]`, `sort` must take another argument, which it doesn't.
However, the next problem is then that you can't sort a list of tuples with arbitrary component types. See @luqui's answer for how to deal with that.
Problem
Sorry for the easy question it's just I'm extremely new to haskell.. I'm trying to write a function "order" which will sort a list of tuples produced by another function "frequency" (frequency counts the number of distinct elements in a list a gives one such result, say > frequency "aabbbccc", would incur the result, [(2,a),(3,b),(3,c)]) into ascending order. I can't work out how to write it. If I write >sort (frequency score) into the prelude it will sort it (score being a list of grades, i.e ["a", "b", "c", "c"]. But when I try to write a function.. ``` results :: [a] -> [(Int, a)] results = sort (frequency score) ``` It sadly does not work saying that sort is applied to too many arguments. Sorry for the obvious question and thanks in advance.