Hi,
I’m trying to sort a list of tuples. A char and a count of that char (Char , Int)
e.g.
[ ('r',2), ('c',2),('a', 2), ('b',3), ('f',2)]
e.g. ‘r’ occurs twice etc.
The order should be based on the count first and then ties broken by the
natural ordering of char.
So
[ ('r',2), ('c',2),('a', 2), ('b',3), ('f',2)]
will sort as
[('b',3),('a', 2), ('c',2),('f',2), ('r',2)]
I initially tried variants on
sortBy (compare `on` snd)
and then made a type Tup = T (Char, Int)
and defined Eq and then got to the point where I felt that this had become too difficult for a simple problem and concluded that I’m missing a point somewhere and need a bit of help!
Many thanks
M